This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new bc50b30af9 Restore fd leak protection
bc50b30af9 is described below
commit bc50b30af92cbc011c1bf27a54497daa9477bcd1
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Jun 30 18:30:04 2026 +0100
Restore fd leak protection
---
.../org/apache/catalina/startup/ContextConfig.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/startup/ContextConfig.java
b/java/org/apache/catalina/startup/ContextConfig.java
index 582f1e05f0..25f9899914 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -1694,24 +1694,44 @@ public class ContextConfig implements LifecycleListener
{
long hostTimeStamp = 0;
if (globalWebXml != null) {
+ URLConnection uc = null;
try {
URI uri = new URI(globalWebXml.getSystemId());
URL url = uri.toURL();
- URLConnection uc = url.openConnection();
+ uc = url.openConnection();
globalTimeStamp = uc.getLastModified();
} catch (IOException | URISyntaxException |
IllegalArgumentException e) {
globalTimeStamp = -1;
+ } finally {
+ if (uc != null) {
+ try {
+ uc.getInputStream().close();
+ } catch (IOException ioe) {
+ ExceptionUtils.handleThrowable(ioe);
+ globalTimeStamp = -1;
+ }
+ }
}
}
if (hostWebXml != null) {
+ URLConnection uc = null;
try {
URI uri = new URI(hostWebXml.getSystemId());
URL url = uri.toURL();
- URLConnection uc = url.openConnection();
+ uc = url.openConnection();
hostTimeStamp = uc.getLastModified();
} catch (IOException | URISyntaxException |
IllegalArgumentException e) {
hostTimeStamp = -1;
+ } finally {
+ if (uc != null) {
+ try {
+ uc.getInputStream().close();
+ } catch (IOException ioe) {
+ ExceptionUtils.handleThrowable(ioe);
+ hostTimeStamp = -1;
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]