Author: robbie
Date: Mon Aug 27 15:56:36 2012
New Revision: 1377724

URL: http://svn.apache.org/viewvc?rev=1377724&view=rev
Log:
QPID-4237: modified FileGroupDatabase to ensure that it always closes its file 
input/output streams.

Applied patch from Philip Harvey <[email protected]>

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java?rev=1377724&r1=1377723&r2=1377724&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
 Mon Aug 27 15:56:36 2012
@@ -192,7 +192,18 @@ public class FileGroupDatabase implement
         _groupToUserMap.clear();
         _userToGroupMap.clear();
         Properties propertiesFile = new Properties();
-        propertiesFile.load(new FileInputStream(groupFile));
+        FileInputStream fileInputStream = new FileInputStream(groupFile);
+        try
+        {
+            propertiesFile.load(fileInputStream);
+        }
+        finally
+        {
+            if(fileInputStream != null)
+            {
+                fileInputStream.close();
+            }
+        }
 
         for (String propertyName : propertiesFile.stringPropertyNames())
         {
@@ -233,7 +244,18 @@ public class FileGroupDatabase implement
         }
 
         String comment = "Written " + new Date();
-        propertiesFile.store(new FileOutputStream(groupFile), comment);
+        FileOutputStream fileOutputStream = new FileOutputStream(groupFile);
+        try
+        {
+            propertiesFile.store(fileOutputStream, comment);
+        }
+        finally
+        {
+            if(fileOutputStream != null)
+            {
+                fileOutputStream.close();
+            }
+        }
     }
 
     private void validatePropertyNameIsGroupName(String propertyName)



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to