Avoid JarURLConnection resource leak in AbstractFileResolvingResource.exists()

Closes gh-34528
This commit is contained in:
Juergen Hoeller 2025-03-03 13:32:51 +01:00
parent 1633ad24f3
commit 5ffaea7a43
1 changed files with 4 additions and 1 deletions

View File

@ -81,7 +81,10 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
} }
} }
} }
if (con.getContentLengthLong() > 0) { // Check content-length entry but not for JarURLConnection where
// this would open the jar file but effectively never close it ->
// for jar entries, always fall back to stream existence instead.
if (!(con instanceof JarURLConnection) && con.getContentLengthLong() > 0) {
return true; return true;
} }
if (httpCon != null) { if (httpCon != null) {