This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 66888e9f0a Fix another potential fd leak
66888e9f0a is described below
commit 66888e9f0a2fcff1b520995b6dc2b5edc3c0a9c9
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Jun 30 20:17:57 2026 +0100
Fix another potential fd leak
---
.../catalina/ssi/SSIServletExternalResolver.java | 25 ++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
index a73cc95c3e..0f0b0241a6 100644
--- a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
+++ b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.connector.Request;
+import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.UDecoder;
import org.apache.tomcat.util.http.Method;
@@ -608,11 +609,21 @@ public class SSIServletExternalResolver implements
SSIExternalResolver {
@Override
public long getFileLastModified(String path, boolean virtual) throws
IOException {
long lastModified = 0;
+ URLConnection urlConnection = null;
try {
- URLConnection urlConnection = getURLConnection(path, virtual);
+ urlConnection = getURLConnection(path, virtual);
lastModified = urlConnection.getLastModified();
} catch (IOException ignore) {
// Ignore this. It will always fail for non-file based includes
+ } finally {
+ if (urlConnection != null) {
+ try {
+ urlConnection.getInputStream().close();
+ } catch (IOException ioe) {
+ ExceptionUtils.handleThrowable(ioe);
+ lastModified = 0;
+ }
+ }
}
return lastModified;
}
@@ -631,11 +642,21 @@ public class SSIServletExternalResolver implements
SSIExternalResolver {
@Override
public long getFileSize(String path, boolean virtual) throws IOException {
long fileSize = -1;
+ URLConnection urlConnection = null;
try {
- URLConnection urlConnection = getURLConnection(path, virtual);
+ urlConnection = getURLConnection(path, virtual);
fileSize = urlConnection.getContentLengthLong();
} catch (IOException ignore) {
// Ignore this. It will always fail for non-file based includes
+ } finally {
+ if (urlConnection != null) {
+ try {
+ urlConnection.getInputStream().close();
+ } catch (IOException ioe) {
+ ExceptionUtils.handleThrowable(ioe);
+ fileSize = -1;
+ }
+ }
}
return fileSize;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]