You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by GitBox <gi...@apache.org> on 2018/12/10 16:56:44 UTC

[GitHub] wtlucy closed pull request #36: MYFACES-4273 close() JarFile in Classpath 2.2.x

wtlucy closed pull request #36: MYFACES-4273 close() JarFile in Classpath 2.2.x
URL: https://github.com/apache/myfaces/pull/36
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
index c82b1b0da..9b59644e6 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
@@ -84,37 +84,47 @@ private static void _searchResource(Set<URL> result, ClassLoader loader, String
             conn.setDefaultUseCaches(false);
 
             JarFile jar = null;
-            if (conn instanceof JarURLConnection)
+            try 
             {
-                try
+                if (conn instanceof JarURLConnection)
                 {
-                    jar = ((JarURLConnection) conn).getJarFile();
+                    try
+                    {
+                        jar = ((JarURLConnection) conn).getJarFile();
+                    }
+                    
+                    catch (Throwable e)
+                    {
+                        // This can happen if the classloader provided us a URL that it thinks exists
+                        // but really doesn't.  In particular, if a JAR contains META-INF/MANIFEST.MF
+                        // but not META-INF/, some classloaders may incorrectly report that META-INF/
+                        // exists and we'll end up here.  Just ignore this case.
+                        
+                        continue;
+                    }
                 }
-                
-                catch (Throwable e)
+                else
                 {
-                    // This can happen if the classloader provided us a URL that it thinks exists
-                    // but really doesn't.  In particular, if a JAR contains META-INF/MANIFEST.MF
-                    // but not META-INF/, some classloaders may incorrectly report that META-INF/
-                    // exists and we'll end up here.  Just ignore this case.
-                    
-                    continue;
+                    jar = _getAlternativeJarFile(url);
                 }
+    
+                if (jar != null)
+                {
+                    _searchJar(loader, result, jar, prefix, suffix);
+                }
+                else
+                {
+                    if (!_searchDir(result, new File(URLDecoder.decode(url.getFile(), "UTF-8")), suffix))
+                    {
+                        _searchFromURL(result, prefix, suffix, url);
+                    }
+                }    
             }
-            else
-            {
-                jar = _getAlternativeJarFile(url);
-            }
-
-            if (jar != null)
-            {
-                _searchJar(loader, result, jar, prefix, suffix);
-            }
-            else
+            finally 
             {
-                if (!_searchDir(result, new File(URLDecoder.decode(url.getFile(), "UTF-8")), suffix))
+                if (jar != null) 
                 {
-                    _searchFromURL(result, prefix, suffix, url);
+                    jar.close();
                 }
             }
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services