From 165ff2da8546db0024d3ffab77e96391c584ab2d Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sun, 6 Jul 2014 23:10:04 +0000 Subject: QPID-5879 : [Java Broker] JsonConfigStore should take deep copy of ConfiguredObjectRecord objects git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1608311 13f79535-47bb-0310-9956-ffa450edef68 --- .../configuration/ConfigurationEntryStore.java | 8 -------- .../qpid/server/store/JsonFileConfigStore.java | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java index 11e92fcff9..d5f7b3a317 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java @@ -25,14 +25,6 @@ import org.apache.qpid.server.store.DurableConfigurationStore; public interface ConfigurationEntryStore extends DurableConfigurationStore { - /** - * Copies the store into the given location - * - * @param target location to copy store into - * @throws IllegalConfigurationException if store cannot be copied into given location - */ - void copyTo(String copyLocation); - /** * Return the store location for the opened store or null if store has not been opened. * diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java index d733c351c4..7a0f57bd33 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java @@ -356,7 +356,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore } else { - + record = new ConfiguredObjectRecordImpl(record); _objectsById.put(record.getId(), record); List idsForType = _idsByType.get(record.getType()); if(idsForType == null) @@ -537,6 +537,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore } for(ConfiguredObjectRecord record : records) { + record = new ConfiguredObjectRecordImpl(record); final UUID id = record.getId(); final String type = record.getType(); if(_objectsById.put(id, record) == null) @@ -623,6 +624,11 @@ public class JsonFileConfigStore implements DurableConfigurationStore private final Map _attributes; private final Map _parents; + private ConfiguredObjectRecordImpl(ConfiguredObjectRecord record) + { + this(record.getId(), record.getType(), record.getAttributes(), convertParents(record.getParents())); + } + private ConfiguredObjectRecordImpl(final UUID id, final String type, final Map attributes, final Map parents) { @@ -678,5 +684,19 @@ public class JsonFileConfigStore implements DurableConfigurationStore } + private static Map convertParents(final Map parents) + { + if(parents == null || parents.isEmpty()) + { + return Collections.emptyMap(); + } + Map parentMap = new HashMap<>(); + for(Map.Entry entry : parents.entrySet()) + { + parentMap.put(entry.getKey(), entry.getValue().getId()); + } + return parentMap; + } + } -- cgit v1.2.1