< prev index next >

src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


  59     URLConnection getConnection(JarFile jarFile) throws IOException {
  60         URL u;
  61         synchronized (instance) {
  62             u = urlCache.get(jarFile);
  63         }
  64         if (u != null)
  65             return u.openConnection();
  66 
  67         return null;
  68     }
  69 
  70     public JarFile get(URL url) throws IOException {
  71         return get(url, true);
  72     }
  73 
  74     JarFile get(URL url, boolean useCaches) throws IOException {
  75         if (url.getProtocol().equalsIgnoreCase("file")) {
  76             // Deal with UNC pathnames specially. See 4180841
  77 
  78             String host = url.getHost();
  79             if (host != null && !host.equals("") &&
  80                 !host.equalsIgnoreCase("localhost")) {
  81 
  82                 url = new URL("file", "", "//" + host + url.getPath());
  83             }
  84         }
  85 
  86         JarFile result;
  87         JarFile local_result;
  88 
  89         if (useCaches) {
  90             synchronized (instance) {
  91                 result = getCachedJarFile(url);
  92             }
  93             if (result == null) {
  94                 local_result = URLJarFile.getJarFile(url, this);
  95                 synchronized (instance) {
  96                     result = getCachedJarFile(url);
  97                     if (result == null) {
  98                         fileCache.put(urlKey(url), local_result);
  99                         urlCache.put(local_result, url);




  59     URLConnection getConnection(JarFile jarFile) throws IOException {
  60         URL u;
  61         synchronized (instance) {
  62             u = urlCache.get(jarFile);
  63         }
  64         if (u != null)
  65             return u.openConnection();
  66 
  67         return null;
  68     }
  69 
  70     public JarFile get(URL url) throws IOException {
  71         return get(url, true);
  72     }
  73 
  74     JarFile get(URL url, boolean useCaches) throws IOException {
  75         if (url.getProtocol().equalsIgnoreCase("file")) {
  76             // Deal with UNC pathnames specially. See 4180841
  77 
  78             String host = url.getHost();
  79             if (host != null && !host.isEmpty() &&
  80                 !host.equalsIgnoreCase("localhost")) {
  81 
  82                 url = new URL("file", "", "//" + host + url.getPath());
  83             }
  84         }
  85 
  86         JarFile result;
  87         JarFile local_result;
  88 
  89         if (useCaches) {
  90             synchronized (instance) {
  91                 result = getCachedJarFile(url);
  92             }
  93             if (result == null) {
  94                 local_result = URLJarFile.getJarFile(url, this);
  95                 synchronized (instance) {
  96                     result = getCachedJarFile(url);
  97                     if (result == null) {
  98                         fileCache.put(urlKey(url), local_result);
  99                         urlCache.put(local_result, url);


< prev index next >