You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2019/06/26 00:54:32 UTC
[logging-log4j2] branch release-2.x updated: LOG4J2-1852 - Close
the JarFile
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new ec81cd6 LOG4J2-1852 - Close the JarFile
ec81cd6 is described below
commit ec81cd665191cbe8a3e7062130dff9c3073c8af7
Author: Ralph Goers <Ra...@dslextreme.com>
AuthorDate: Tue Jun 25 18:54:21 2019 -0600
LOG4J2-1852 - Close the JarFile
---
.../log4j/core/config/plugins/util/ResolverUtil.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
index 016efcf..7611ee6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
@@ -342,13 +342,14 @@ public class ResolverUtil {
try {
connection = (JarURLConnection) url.openConnection();
if (connection != null) {
- JarFile jarFile = connection.getJarFile();
- Enumeration<JarEntry> entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- final String name = entry.getName();
- if (!entry.isDirectory() && name.startsWith(parent) && isTestApplicable(test, name)) {
- addIfMatching(test, name);
+ try (JarFile jarFile = connection.getJarFile()) {
+ Enumeration<JarEntry> entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ final String name = entry.getName();
+ if (!entry.isDirectory() && name.startsWith(parent) && isTestApplicable(test, name)) {
+ addIfMatching(test, name);
+ }
}
}
} else {