Author: remy.maucherat(a)jboss.com
Date: 2014-10-03 11:06:41 -0400 (Fri, 03 Oct 2014)
New Revision: 2514
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/startup/ContextConfig.java
branches/7.5.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java
branches/7.5.x/src/main/java/org/apache/tomcat/util/http/HttpMessages.java
Log:
BZ1149211: Close some IS, submitted by Radim Hatlapatka.
Modified: branches/7.5.x/src/main/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/startup/ContextConfig.java 2014-10-03
14:57:36 UTC (rev 2513)
+++ branches/7.5.x/src/main/java/org/apache/catalina/startup/ContextConfig.java 2014-10-03
15:06:41 UTC (rev 2514)
@@ -87,8 +87,9 @@
static {
// Load our mapping properties
authenticators = new Properties();
+ InputStream is = null;
try {
- InputStream is =
ContextConfig.class.getClassLoader().getResourceAsStream("org/apache/catalina/startup/Authenticators.properties");
+ is =
ContextConfig.class.getClassLoader().getResourceAsStream("org/apache/catalina/startup/Authenticators.properties");
if (is != null) {
authenticators.load(is);
} else {
@@ -96,6 +97,14 @@
}
} catch (IOException e) {
CatalinaLogger.STARTUP_LOGGER.failedLoadingAuthenticatoMappings(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
}
}
Modified: branches/7.5.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java 2014-10-03
14:57:36 UTC (rev 2513)
+++ branches/7.5.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java 2014-10-03
15:06:41 UTC (rev 2514)
@@ -242,8 +242,18 @@
return false;
}
String resourceName = result.replace('.', '/') +
".class";
- InputStream is =
- classLoader.getResourceAsStream(resourceName);
+ InputStream is = null;
+ try {
+ is = classLoader.getResourceAsStream(resourceName);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
return is == null;
}
Modified: branches/7.5.x/src/main/java/org/apache/tomcat/util/http/HttpMessages.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/tomcat/util/http/HttpMessages.java 2014-10-03
14:57:36 UTC (rev 2513)
+++ branches/7.5.x/src/main/java/org/apache/tomcat/util/http/HttpMessages.java 2014-10-03
15:06:41 UTC (rev 2514)
@@ -17,6 +17,7 @@
package org.apache.tomcat.util.http;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@@ -36,11 +37,20 @@
protected static Properties statusMessages = new Properties();
static {
+ InputStream is = null;
try {
- InputStream is =
HttpMessages.class.getClassLoader().getResourceAsStream("org/apache/tomcat/util/http/HttpMessages.properties");
+ is =
HttpMessages.class.getClassLoader().getResourceAsStream("org/apache/tomcat/util/http/HttpMessages.properties");
statusMessages.load(is);
} catch (Exception e) {
CoyoteLogger.HTTP_LOGGER.errorLoadingMessages(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
}
}
Show replies by date