Add try-with-resources to close stream

Closes gh-9041
This commit is contained in:
Malyshau Stanislau 2020-09-27 21:01:18 +03:00 committed by Josh Cummings
parent dc5f2444ae
commit 6d14482378
1 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@
package org.springframework.security.core;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
@ -103,9 +104,9 @@ public final 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 ex) {
return null;