Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2008-04-14 14:06:50 +0000
committerJohn Arthorne2008-04-14 14:06:50 +0000
commit1b3091b2b6a1cab170ea373ccb1b8b8886bc2cbe (patch)
treefbfb591843c4229e723fd4311f1649eae62c1fde /bundles/org.eclipse.equinox.p2.repository/src
parent4386bc70e3ba276a553c165c11b7af4197175a6c (diff)
downloadrt.equinox.p2-1b3091b2b6a1cab170ea373ccb1b8b8886bc2cbe.tar.gz
rt.equinox.p2-1b3091b2b6a1cab170ea373ccb1b8b8886bc2cbe.tar.xz
rt.equinox.p2-1b3091b2b6a1cab170ea373ccb1b8b8886bc2cbe.zip
Bug 226929 CacheManager uses URL.hashCode()
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
index 905db1687..72678305d 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
@@ -39,6 +39,14 @@ public class CacheManager {
private static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$
/**
+ * Returns a hash of the URL.
+ */
+ private int computeHash(URL repositoryLocation) {
+ //don't use URL#hashCode because it performs DNS lookups
+ return repositoryLocation.toExternalForm().hashCode();
+ }
+
+ /**
* Returns a local cache file with the contents of the given remote location,
* or <code>null</code> if a local cache could not be created.
*
@@ -56,7 +64,7 @@ public class CacheManager {
AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$
File dataAreaFile = URLUtil.toFile(dataArea);
- int hashCode = repositoryLocation.hashCode();
+ int hashCode = computeHash(repositoryLocation);
if (cacheFile == null || isCacheStale(repositoryLocation, cacheFile)) {
long lastModifiedRemote = getTransport().getLastModified(jarLocation);
URL remoteFile;
@@ -105,7 +113,7 @@ public class CacheManager {
AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$
File dataAreaFile = URLUtil.toFile(dataArea);
- int hashCode = repositoryLocation.hashCode();
+ int hashCode = computeHash(repositoryLocation);
File cacheFile = new File(dataAreaFile, CONTENT_FILENAME + hashCode + JAR_EXTENSION);
if (!cacheFile.exists()) {
cacheFile = new File(dataAreaFile, CONTENT_FILENAME + hashCode + XML_EXTENSION);

Back to the top