summaryrefslogtreecommitdiff
path: root/java/broker-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/broker-core/src')
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java10
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java17
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java18
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java20
4 files changed, 42 insertions, 23 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
index e67191b744..812ffc618d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
@@ -1324,6 +1324,16 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
return _attributeResolver;
}
+ protected boolean isAttributePersisted(String name)
+ {
+ ConfiguredObjectAttribute<X,?> attr = (ConfiguredObjectAttribute<X, ?>) _attributeTypes.get(name);
+ if(attr != null)
+ {
+ return attr.isPersisted();
+ }
+ return false;
+ }
+
//=========================================================================================
static String interpolate(ConfiguredObject<?> object, String value)
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 dcacb1ae7f..afdd3a9136 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
@@ -378,7 +378,11 @@ public class JsonFileConfigStore implements DurableConfigurationStore
List<UUID> ids = _idsByType.get(_rootClass.getSimpleName());
if (ids == null)
{
- throw new IllegalStateException("Root entry of type " + _rootClass.getSimpleName() + " does not exist in the store.");
+ return null;
+ }
+ if (ids.size() == 0)
+ {
+ return null;
}
return ids.get(0);
}
@@ -386,7 +390,16 @@ public class JsonFileConfigStore implements DurableConfigurationStore
private void save()
{
UUID rootId = getRootId();
- Map<String, Object> data = build(_rootClass, rootId);
+ Map<String, Object> data = null;
+
+ if (rootId == null)
+ {
+ data = Collections.emptyMap();
+ }
+ else
+ {
+ data = build(_rootClass, rootId);
+ }
try
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
index 86c19941f8..26da911e1f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
@@ -695,16 +695,6 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
_eventLogger.message(VirtualHostMessages.CLOSED(getName()));
}
- @Override
- protected void changeAttributes(final Map<String, Object> attributes)
- {
- super.changeAttributes(attributes);
- if (isDurable() && getState() != State.DELETED)
- {
- getDurableConfigurationStore().update(false, asObjectRecord());
- }
- }
-
private void closeMessageStore()
{
if (getMessageStore() != null)
@@ -1447,7 +1437,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
@Override
public void stateChanged(final ConfiguredObject<?> object, final State oldState, final State newState)
{
- if (newState == State.DELETED)
+ if (object == AbstractVirtualHost.this && isDurable() && newState == State.DELETED)
{
getDurableConfigurationStore().remove(asObjectRecord());
object.removeChangeListener(this);
@@ -1472,7 +1462,11 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
final Object oldAttributeValue,
final Object newAttributeValue)
{
- getDurableConfigurationStore().update(false, asObjectRecord());
+ if (object == AbstractVirtualHost.this && isDurable() && getState() != State.DELETED && isAttributePersisted(attributeName)
+ && !(attributeName.equals(VirtualHost.DESIRED_STATE) && newAttributeValue.equals(State.DELETED)))
+ {
+ getDurableConfigurationStore().update(false, asObjectRecord());
+ }
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
index 2f8860a3a0..f52558e298 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
@@ -194,23 +194,25 @@ public abstract class AbstractVirtualHostNode<X extends AbstractVirtualHostNode<
@StateTransition( currentState = { State.ACTIVE, State.STOPPED, State.ERRORED}, desiredState = State.DELETED )
protected void doDelete()
{
-
- close();
_state.set(State.DELETED);
- VirtualHost<?, ?, ?> virtualHost = getVirtualHost();
- if (virtualHost != null)
- {
- virtualHost.delete();
- }
-
+ deleteVirtualHostIfExists();
+ close();
deleted();
-
if (getConfigurationStore() instanceof MessageStore)
{
((MessageStore)getConfigurationStore()).onDelete();
}
}
+ protected void deleteVirtualHostIfExists()
+ {
+ VirtualHost<?, ?, ?> virtualHost = getVirtualHost();
+ if (virtualHost != null)
+ {
+ virtualHost.delete();
+ }
+ }
+
@StateTransition( currentState = { State.ACTIVE, State.ERRORED, State.UNINITIALIZED }, desiredState = State.STOPPED )
protected void doStop()
{