Skip to content

Commit

Permalink
RemoteRepositoryCacheManager should never throw the REPOSITOY_NOT_FOU…
Browse files Browse the repository at this point in the history
…ND (#211)

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 authored Aug 6, 2021
1 parent 01f66d1 commit c19c5e1
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ 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 +106,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 +120,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 c19c5e1

Please sign in to comment.