From 3379b07c73a1dfb383d13c509cd65a5959a662b2 Mon Sep 17 00:00:00 2001 From: Johan Compagner Date: Tue, 3 Aug 2021 00:18:16 +0200 Subject: [PATCH] RemoteRepositoryCacheManager should never throw the REPOSITOY_NOT_FOUND because other metadata (xml, xml.jar or xml.jar.xz) could be found in the cache, it shouldn't break directly with the first (content.xml) --- .../p2/remote/RemoteRepositoryCacheManager.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java index 09a2ee78fc..c70cf0a363 100644 --- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java +++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java @@ -77,14 +77,19 @@ public File createCache(URI repositoryLocation, String prefix, IProgressMonitor @Override public File createCacheFromFile(URI remoteFile, IProgressMonitor monitor) throws ProvisionException, IOException { + File cacheFile = getCacheFile(remoteFile, getCacheDirectory()); if (offline) { - File cacheFile = getCacheFile(remoteFile, getCacheDirectory()); if (cacheFile != null) { return cacheFile; } - throw new ProvisionException(getFailureStatus(remoteFile)); } - return super.createCacheFromFile(remoteFile, monitor); + try { + return super.createCacheFromFile(remoteFile, monitor); + } catch (IOException e) { + return handleCreateCacheException(cacheFile, remoteFile, e); + } catch (ProvisionException e) { + return handleCreateCacheException(cacheFile, remoteFile, e); + } } private Status getFailureStatus(URI uri) throws ProvisionException { @@ -100,8 +105,8 @@ public static File getCacheFile(URI url, File dataAreaFile) { return new File(dataAreaFile, Integer.toString(hashCode)); } - private File handleCreateCacheException(File cacheFile, URI repositoryLocation, T e) - throws T { + private File handleCreateCacheException(File cacheFile, URI repositoryLocation, Exception e) + throws ProvisionException { if (cacheFile != null) { String message = "Failed to access p2 repository " + repositoryLocation.toASCIIString() + ", use local cache."; @@ -114,7 +119,7 @@ private File handleCreateCacheException(File cacheFile, UR // original exception has been already logged return cacheFile; } - throw e; + throw new ProvisionException(getFailureStatus(repositoryLocation)); } @Override