From 6aed9408e13fae7aea13df129a5f68f9f1240133 Mon Sep 17 00:00:00 2001 From: Malyshau Stanislau Date: Sun, 27 Sep 2020 21:01:18 +0300 Subject: [PATCH] Add try-with-resources to close stream Closes gh-9041 --- .../security/core/SpringSecurityCoreVersion.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java b/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java index 8b38d07706..61990be61e 100644 --- a/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java +++ b/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.core.SpringVersion; import java.io.IOException; +import java.io.InputStream; import java.util.Properties; /** @@ -108,8 +109,9 @@ public class SpringSecurityCoreVersion { */ private static String getSpringVersion() { Properties properties = new Properties(); - try { - properties.load(SpringSecurityCoreVersion.class.getClassLoader().getResourceAsStream("META-INF/spring-security.versions")); + try (InputStream is = SpringSecurityCoreVersion.class.getClassLoader() + .getResourceAsStream("META-INF/spring-security.versions")) { + properties.load(is); } catch (IOException | NullPointerException e) { return null; }