diff options
Diffstat (limited to 'jimfs/src/main/java/com')
-rw-r--r-- | jimfs/src/main/java/com/google/common/jimfs/Handler.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Handler.java b/jimfs/src/main/java/com/google/common/jimfs/Handler.java index e5bfcbf..fd4ab74 100644 --- a/jimfs/src/main/java/com/google/common/jimfs/Handler.java +++ b/jimfs/src/main/java/com/google/common/jimfs/Handler.java @@ -19,6 +19,7 @@ package com.google.common.jimfs; import static com.google.common.base.Preconditions.checkArgument; import java.io.IOException; +import java.net.InetAddress; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -77,4 +78,15 @@ public final class Handler extends URLStreamHandler { protected URLConnection openConnection(URL url) throws IOException { return new PathURLConnection(url); } + + @Override + @SuppressWarnings("UnsynchronizedOverridesSynchronized") // no need to synchronize to return null + protected InetAddress getHostAddress(URL url) { + // jimfs uses the URI host to specify the name of the file system being used. + // In the default implementation of getHostAddress(URL), a non-null host would cause an attempt + // to look up the IP address, causing a slowdown on calling equals/hashCode methods on the URL + // object. By returning null, we speed up equality checks on URL's (since there isn't an IP to + // connect to). + return null; + } } |