Skip to content

Commit 5ffaea7

Browse files
committed
Avoid JarURLConnection resource leak in AbstractFileResolvingResource.exists()
Closes gh-34528
1 parent 1633ad2 commit 5ffaea7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-core/src/main/java/org/springframework/core/io/AbstractFileResolvingResource.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
8181
}
8282
}
8383
}
84-
if (con.getContentLengthLong() > 0) {
84+
// Check content-length entry but not for JarURLConnection where
85+
// this would open the jar file but effectively never close it ->
86+
// for jar entries, always fall back to stream existence instead.
87+
if (!(con instanceof JarURLConnection) && con.getContentLengthLong() > 0) {
8588
return true;
8689
}
8790
if (httpCon != null) {

0 commit comments

Comments
 (0)