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 | addf196166c5bb993293bd3b9e7cd4b78781c28d (patch) | |
| tree | 395d65279ffa967dd308ab15444bfd1c335abc5d | |
| parent | 3de48cb0769eac9b8db9e06c2f35a01c2c92bd94 (diff) | |
| download | qpid-python-addf196166c5bb993293bd3b9e7cd4b78781c28d.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/qpid@1377724 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java b/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java index 2e4fc9e3a3..c66e7fd4e4 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java +++ b/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) |
