Skip to content

Commit

Permalink
RemoteRepositoryCacheManager should never throw the REPOSITOY_NOT_FOUND
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jcompagner committed Aug 3, 2021
1 parent 53e395a commit 3379b07
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -100,8 +105,8 @@ public static File getCacheFile(URI url, File dataAreaFile) {
return new File(dataAreaFile, Integer.toString(hashCode));
}

private <T extends Exception> 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.";
Expand All @@ -114,7 +119,7 @@ private <T extends Exception> File handleCreateCacheException(File cacheFile, UR
// original exception has been already logged
return cacheFile;
}
throw e;
throw new ProvisionException(getFailureStatus(repositoryLocation));
}

@Override
Expand Down

0 comments on commit 3379b07

Please sign in to comment.