diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java b/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java index 4b63419c3f9..c4c536166df 100644 --- a/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java +++ b/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java @@ -175,7 +175,10 @@ public void run() { deactivate(); } - activate(holder.getPersistenceManager()); + if (!holder.isActivated()) { + activate(holder.getPersistenceManager()); + holder.activate(); + } } }); } @@ -197,7 +200,7 @@ public void modifiedService(final ServiceReference reference this.holders.remove(holder); this.holders.add(new Holder(reference, holder.getPersistenceManager())); Collections.sort(this.holders); - if ( holders.get(0) == holder && oldHolder.compareTo(holder) != 0 ) + if ( holders.get(0) == holder && oldHolder != null && oldHolder.compareTo(holder) != 0 ) { this.workerQueue.enqueue(new Runnable() { @@ -206,7 +209,10 @@ public void modifiedService(final ServiceReference reference public void run() { deactivate(); - activate(holder.getPersistenceManager()); + if (!holder.isActivated()) { + activate(holder.getPersistenceManager()); + holder.activate(); + } } }); } @@ -234,7 +240,11 @@ public void run() deactivate(); if ( !holders.isEmpty() ) { - activate(holders.get(0).getPersistenceManager()); + Holder h = holders.get(0); + if (!h.isActivated()) { + activate(h.getPersistenceManager()); + h.activate(); + } } } }); @@ -248,6 +258,9 @@ public static final class Holder implements Comparable private final ExtPersistenceManager manager; + // no need to synchronize, as it's changed only in WorkQueue tasks + private boolean activated; + public Holder(final ServiceReference ref, final ExtPersistenceManager epm) { this.reference = ref; @@ -266,6 +279,14 @@ public int compareTo(final Holder o) return -reference.compareTo(o.reference); } + public boolean isActivated() { + return activated; + } + + public void activate() { + this.activated = true; + } + @Override public int hashCode() {