diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/SharedHttpCacheStorage.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/SharedHttpCacheStorage.java index d29a3ea36e..8621450136 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/SharedHttpCacheStorage.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/SharedHttpCacheStorage.java @@ -90,14 +90,15 @@ protected boolean removeEldestEntry(final Map.Entry eldest) { */ @Override public CacheEntry getCacheEntry(URI uri, Logger logger) throws FileNotFoundException { - CacheLine cacheLine = getCacheLine(uri); + URI normalized = uri.normalize(); + CacheLine cacheLine = getCacheLine(normalized); if (!cacheConfig.isUpdate()) { // if not updates are forced ... int code = cacheLine.getResponseCode(); if (code == HttpURLConnection.HTTP_NOT_FOUND) { - throw new FileNotFoundException(uri.toASCIIString()); + throw new FileNotFoundException(normalized.toASCIIString()); } if (code == HttpURLConnection.HTTP_MOVED_PERM) { - return getCacheEntry(cacheLine.getRedirect(uri), logger); + return getCacheEntry(cacheLine.getRedirect(normalized), logger); } } return new CacheEntry() { @@ -106,19 +107,19 @@ public CacheEntry getCacheEntry(URI uri, Logger logger) throws FileNotFoundExcep public long getLastModified(HttpTransportFactory transportFactory) throws IOException { if (cacheConfig.isOffline()) { - return cacheLine.getLastModified(uri, transportFactory, + return cacheLine.getLastModified(normalized, transportFactory, SharedHttpCacheStorage::mavenIsOffline, logger); } try { - return cacheLine.fetchLastModified(uri, transportFactory, logger); + return cacheLine.fetchLastModified(normalized, transportFactory, logger); } catch (FileNotFoundException | AuthenticationFailedException e) { //for not found and failed authentication we can't do anything useful throw e; } catch (IOException e) { if (!cacheConfig.isUpdate() && cacheLine.getResponseCode() > 0) { //if we have something cached, use that ... - logger.warn("Request to " + uri + " failed, trying cache instead"); - return cacheLine.getLastModified(uri, transportFactory, nil -> e, logger); + logger.warn("Request to " + normalized + " failed, trying cache instead"); + return cacheLine.getLastModified(normalized, transportFactory, nil -> e, logger); } throw e; } @@ -128,19 +129,19 @@ public long getLastModified(HttpTransportFactory transportFactory) public File getCacheFile(HttpTransportFactory transportFactory) throws IOException { if (cacheConfig.isOffline()) { - return cacheLine.getFile(uri, transportFactory, + return cacheLine.getFile(normalized, transportFactory, SharedHttpCacheStorage::mavenIsOffline, logger); } try { - return cacheLine.fetchFile(uri, transportFactory, logger); + return cacheLine.fetchFile(normalized, transportFactory, logger); } catch (FileNotFoundException | AuthenticationFailedException e) { //for not found and failed authentication we can't do anything useful throw e; } catch (IOException e) { if (!cacheConfig.isUpdate() && cacheLine.getResponseCode() > 0) { //if we have something cached, use that ... - logger.warn("Request to " + uri + " failed, trying cache instead"); - return cacheLine.getFile(uri, transportFactory, nil -> e, logger); + logger.warn("Request to " + normalized + " failed, trying cache instead"); + return cacheLine.getFile(normalized, transportFactory, nil -> e, logger); } throw e; }