summaryrefslogtreecommitdiff
path: root/java/broker-core/src
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-06-19 21:31:23 +0000
committerKeith Wall <kwall@apache.org>2014-06-19 21:31:23 +0000
commita237d1d34a0251e8daee78137a6a33770b03ed94 (patch)
tree9b720c11f56f37b046bed5d587788513ede6f150 /java/broker-core/src
parent6071a5f23ae85eb7a3fb469f43250c7e5a37fda7 (diff)
downloadqpid-python-a237d1d34a0251e8daee78137a6a33770b03ed94.tar.gz
QPID-5819: Make JsonFileConfigStore#close idempotent, like other DCS implementations
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1604036 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker-core/src')
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java27
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java9
2 files changed, 24 insertions, 12 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
index afb2179b9b..f787bd63ad 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
@@ -564,17 +564,11 @@ public class JsonFileConfigStore implements DurableConfigurationStore
{
releaseFileLock();
}
- catch (IOException e)
- {
- throw new StoreException("Failed to release lock", e);
- }
finally
{
- _fileLock = null;
_idsByType.clear();
_objectsById.clear();
}
-
}
@Override
@@ -588,13 +582,26 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
}
- private void releaseFileLock() throws IOException
+ private void releaseFileLock()
{
- _fileLock.release();
- _fileLock.channel().close();
+ if (_fileLock != null)
+ {
+ try
+ {
+ _fileLock.release();
+ _fileLock.channel().close();
+ }
+ catch (IOException e)
+ {
+ throw new StoreException("Failed to release lock " + _fileLock, e);
+ }
+ finally
+ {
+ _fileLock = null;
+ }
+ }
}
-
private static Map<String,Class<? extends ConfiguredObject>> generateClassNameMap(final Model model,
final Class<? extends ConfiguredObject> clazz)
{
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index 4dc9fbe1f0..96ee8195a2 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -64,8 +64,6 @@ import org.apache.qpid.util.FileUtils;
public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTestCase
{
- private static final String EXCHANGE_NAME = "exchangeName";
-
private static final String EXCHANGE = org.apache.qpid.server.model.Exchange.class.getSimpleName();
private static final String BINDING = org.apache.qpid.server.model.Binding.class.getSimpleName();
private static final String QUEUE = Queue.class.getSimpleName();
@@ -139,6 +137,13 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
}
}
+ public void testCloseIsIdempotent() throws Exception
+ {
+ _configStore.closeConfigurationStore();
+ // Second close should be accepted without exception
+ _configStore.closeConfigurationStore();
+ }
+
public void testCreateExchange() throws Exception
{
ExchangeImpl exchange = createTestExchange();