From e4556b156365171e52ab54282af39b34a67f90a7 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Mon, 27 Aug 2012 15:56:36 +0000 Subject: QPID-4237: modified FileGroupDatabase to ensure that it always closes its file input/output streams. Applied patch from Philip Harvey git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1377724 13f79535-47bb-0310-9956-ffa450edef68 --- .../server/security/group/FileGroupDatabase.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'qpid/java') 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) -- cgit v1.2.1