Fixed - Resources leak in Version.logVersion() #5478

pull/5477/merge
Nikita Koksharov 1 year ago
parent aa606742e4
commit 948286d41a

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.jar.Attributes; import java.util.jar.Attributes;
@ -31,7 +32,8 @@ public class Version {
try { try {
Enumeration<URL> resources = Version.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); Enumeration<URL> resources = Version.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream()); try (InputStream inputStream = resources.nextElement().openStream()) {
Manifest manifest = new Manifest(inputStream);
Attributes attrs = manifest.getMainAttributes(); Attributes attrs = manifest.getMainAttributes();
if (attrs == null) { if (attrs == null) {
continue; continue;
@ -41,6 +43,7 @@ public class Version {
log.info("Redisson {}", attrs.getValue("Bundle-Version")); log.info("Redisson {}", attrs.getValue("Bundle-Version"));
break; break;
} }
}
} }
} catch (Exception E) { } catch (Exception E) {
// skip it // skip it

Loading…
Cancel
Save