You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/03/06 21:56:11 UTC
svn commit: r1297717 -
/tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java
Author: markt
Date: Tue Mar 6 20:56:10 2012
New Revision: 1297717
URL: http://svn.apache.org/viewvc?rev=1297717&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52726
Clean-up. Avoid unlikely fd leak.
Modified:
tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java
Modified: tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java?rev=1297717&r1=1297716&r2=1297717&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java Tue Mar 6 20:56:10 2012
@@ -14,11 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.users;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -35,13 +32,11 @@ import org.apache.catalina.User;
import org.apache.catalina.UserDatabase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.digester.AbstractObjectCreationFactory;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.res.StringManager;
import org.xml.sax.Attributes;
-
/**
* <p>Concrete implementation of {@link UserDatabase} that loads all
* defined users, groups, and roles into an in-memory data structure,
@@ -51,7 +46,6 @@ import org.xml.sax.Attributes;
* @version $Id$
* @since 4.1
*/
-
public class MemoryUserDatabase implements UserDatabase {
@@ -410,7 +404,6 @@ public class MemoryUserDatabase implemen
if (!file.exists()) {
return;
}
- FileInputStream fis = new FileInputStream(file);
// Construct a digester to read the XML input file
Digester digester = new Digester();
@@ -432,16 +425,18 @@ public class MemoryUserDatabase implemen
new MemoryUserCreationFactory(this), true);
// Parse the XML input file to load this database
+ FileInputStream fis = null;
try {
+ fis = new FileInputStream(file);
digester.parse(fis);
- fis.close();
- } catch (Exception e) {
- try {
- fis.close();
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ // Ignore
+ }
}
- throw e;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org