summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-08-27 15:56:36 +0000
committerRobert Gemmell <robbie@apache.org>2012-08-27 15:56:36 +0000
commite4556b156365171e52ab54282af39b34a67f90a7 (patch)
tree3f63372e8dc40e52f6c077a36f9e98491783eaab /qpid/java
parent6be80b8e052d8fcba568c33583f0555843f588e2 (diff)
downloadqpid-python-e4556b156365171e52ab54282af39b34a67f90a7.tar.gz
QPID-4237: modified FileGroupDatabase to ensure that it always closes its file input/output streams.
Applied patch from Philip Harvey <phil@philharveyonline.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1377724 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
index 2e4fc9e3a3..c66e7fd4e4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
@@ -192,7 +192,18 @@ public class FileGroupDatabase implements GroupDatabase
_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 implements GroupDatabase
}
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)