Skip to content

Commit 6aed940

Browse files
stanislav-malyshau-idfjzheaux
authored andcommitted
Add try-with-resources to close stream
Closes gh-9041
1 parent dec0368 commit 6aed940

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.core.SpringVersion;
2222

2323
import java.io.IOException;
24+
import java.io.InputStream;
2425
import java.util.Properties;
2526

2627
/**
@@ -108,8 +109,9 @@ private static boolean disableChecks(String springVersion,
108109
*/
109110
private static String getSpringVersion() {
110111
Properties properties = new Properties();
111-
try {
112-
properties.load(SpringSecurityCoreVersion.class.getClassLoader().getResourceAsStream("META-INF/spring-security.versions"));
112+
try (InputStream is = SpringSecurityCoreVersion.class.getClassLoader()
113+
.getResourceAsStream("META-INF/spring-security.versions")) {
114+
properties.load(is);
113115
} catch (IOException | NullPointerException e) {
114116
return null;
115117
}

0 commit comments

Comments
 (0)