felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1854973 - /felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java
Date Thu, 07 Mar 2019 12:27:15 GMT
Author: jbonofre
Date: Thu Mar  7 12:27:15 2019
New Revision: 1854973

URL: http://svn.apache.org/viewvc?rev=1854973&view=rev
Log:
[FELIX-6066] This closes #185

Modified:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java?rev=1854973&r1=1854972&r2=1854973&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java
(original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerTracker.java
Thu Mar  7 12:27:15 2019
@@ -175,7 +175,10 @@ public class PersistenceManagerTracker
                             {
                                 deactivate();
                             }
-                            activate(holder.getPersistenceManager());
+                            if (!holder.isActivated()) {
+                                activate(holder.getPersistenceManager());
+                                holder.activate();
+                            }
                         }
                     });
                 }
@@ -197,7 +200,7 @@ public class PersistenceManagerTracker
             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 class PersistenceManagerTracker
                     public void run()
                     {
                         deactivate();
-                        activate(holder.getPersistenceManager());
+                        if (!holder.isActivated()) {
+                            activate(holder.getPersistenceManager());
+                            holder.activate();
+                        }
                     }
                 });
             }
@@ -234,7 +240,11 @@ public class PersistenceManagerTracker
                         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 class PersistenceManagerTracker
 
         private final ExtPersistenceManager manager;
 
+        // no need to synchronize, as it's changed only in WorkQueue tasks
+        private boolean activated;
+
         public Holder(final ServiceReference<PersistenceManager> ref, final ExtPersistenceManager
epm)
         {
             this.reference = ref;
@@ -266,6 +279,14 @@ public class PersistenceManagerTracker
             return -reference.compareTo(o.reference);
         }
 
+        public boolean isActivated() {
+            return activated;
+        }
+
+        public void activate() {
+            this.activated = true;
+        }
+
         @Override
         public int hashCode()
         {



Mime
View raw message