diff options
| author | Robert Gemmell <robbie@apache.org> | 2012-08-27 15:56:36 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2012-08-27 15:56:36 +0000 |
| commit | e4556b156365171e52ab54282af39b34a67f90a7 (patch) | |
| tree | 3f63372e8dc40e52f6c077a36f9e98491783eaab /qpid/java | |
| parent | 6be80b8e052d8fcba568c33583f0555843f588e2 (diff) | |
| download | qpid-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.java | 26 |
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) |
