You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2014/09/03 19:51:34 UTC

svn commit: r1622306 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/util/ServerInfo.java webapps/docs/changelog.xml

Author: violetagg
Date: Wed Sep  3 17:51:34 2014
New Revision: 1622306

URL: http://svn.apache.org/r1622306
Log:
Merged revision 1622297 from tomcat/trunk:
Fix some potential resource leaks when reading property files. Reported by Coverity Scan.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ServerInfo.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1622297

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ServerInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ServerInfo.java?rev=1622306&r1=1622305&r2=1622306&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ServerInfo.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ServerInfo.java Wed Sep  3 17:51:34 2014
@@ -19,6 +19,7 @@
 package org.apache.catalina.util;
 
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 
@@ -54,17 +55,24 @@ public class ServerInfo {
 
     static {
 
+        Properties props = new Properties();
+        InputStream is = null;
         try {
-            InputStream is = ServerInfo.class.getResourceAsStream
-                ("/org/apache/catalina/util/ServerInfo.properties");
-            Properties props = new Properties();
+            is = ServerInfo.class.getResourceAsStream
+                    ("/org/apache/catalina/util/ServerInfo.properties");
             props.load(is);
-            is.close();
             serverInfo = props.getProperty("server.info");
             serverBuilt = props.getProperty("server.built");
             serverNumber = props.getProperty("server.number");
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                }
+            }
         }
         if (serverInfo == null)
             serverInfo = "Apache Tomcat 7.0.x-dev";

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1622306&r1=1622305&r2=1622306&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Sep  3 17:51:34 2014
@@ -145,6 +145,10 @@
         <bug>56848</bug>: Improve handling of <code>accept-language</code>
         headers. (markt)
       </fix>
+      <fix>
+        Fix some potential resource leaks when reading property files. Reported
+        by Coverity Scan. (violetagg)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org