[
https://issues.apache.org/jira/browse/MYFACES-4273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16715010#comment-16715010
]
ASF GitHub Bot commented on MYFACES-4273:
-----------------------------------------
wtlucy closed pull request #35: MYFACES-4273 close() JarFile in Classpath 2.3.x
URL: https://github.com/apache/myfaces/pull/35
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..85789169e 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
@@ -83,39 +83,28 @@ private static void _searchResource(Set<URL> result,
ClassLoader loader, String
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
- JarFile jar = null;
- if (conn instanceof JarURLConnection)
+ try (JarFile jar = (conn instanceof JarURLConnection) ?
+ ((JarURLConnection) conn).getJarFile() :
_getAlternativeJarFile(url))
{
- try
+ if (jar != null)
{
- jar = ((JarURLConnection) conn).getJarFile();
+ _searchJar(loader, result, jar, prefix, suffix);
}
-
- 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;
+ if (!_searchDir(result, new
File(URLDecoder.decode(url.getFile(), "UTF-8")), suffix))
+ {
+ _searchFromURL(result, prefix, suffix, url);
+ }
}
}
- else
+ catch (Throwable e)
{
- 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);
- }
+ // 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;
}
}
}
----------------------------------------------------------------
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:
[email protected]
> JarFile never released in oam.view.facelets.util.ClassPath
> ----------------------------------------------------------
>
> Key: MYFACES-4273
> URL: https://issues.apache.org/jira/browse/MYFACES-4273
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.0.24, 2.1.18, 2.2.12, 2.3.2, 3.0.0-SNAPSHOT
> Reporter: Bill Lucy
> Assignee: Bill Lucy
> Priority: Minor
>
> JarFiles opened in ClassPath._searchResource() aren't ever closed. This can
> cause a leak, and in some environments that causes problems removing apps
> after shutdown.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)