felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1712478 - in /felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl: CoordinationHolder.java CoordinationImpl.java CoordinationMgr.java CoordinatorImpl.java
Date Wed, 04 Nov 2015 06:43:34 GMT
Author: cziegeler
Date: Wed Nov  4 06:43:34 2015
New Revision: 1712478

URL: http://svn.apache.org/viewvc?rev=1712478&view=rev
Log:
FELIX-5086 : Coordinator.begin can return null

Modified:
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationHolder.java
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationHolder.java?rev=1712478&r1=1712477&r2=1712478&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationHolder.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationHolder.java
Wed Nov  4 06:43:34 2015
@@ -35,10 +35,11 @@ import org.osgi.service.coordinator.Part
  */
 public class CoordinationHolder implements Coordination {
 
-    private final CoordinationImpl coordination;
+    private CoordinationImpl coordination;
 
-	public CoordinationHolder(final CoordinationImpl coordination) {
-		this.coordination = coordination;
+	public void setCoordination(final CoordinationImpl coordination) 
+	{
+	    this.coordination = coordination;
 	}
 
     /**

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java?rev=1712478&r1=1712477&r2=1712478&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
Wed Nov  4 06:43:34 2015
@@ -80,7 +80,19 @@ public class CoordinationImpl implements
 
     private final Object waitLock = new Object();
 
-    public CoordinationImpl(final CoordinatorImpl owner, final long id, final String name,
final long timeOutInMs)
+    public static CoordinationMgr.CreationResult create(final CoordinatorImpl owner, final
long id, final String name, final long timeOutInMs)
+    {
+        final CoordinationMgr.CreationResult result = new CoordinationMgr.CreationResult();
+        result.holder = new CoordinationHolder();
+        result.coordination = new CoordinationImpl(owner, id, name, timeOutInMs, result.holder);
+        return result;
+    }
+
+    private CoordinationImpl(final CoordinatorImpl owner,
+            final long id,
+            final String name,
+            final long timeOutInMs,
+            final CoordinationHolder holder)
     {
         this.owner = owner;
         this.id = id;
@@ -89,8 +101,8 @@ public class CoordinationImpl implements
         this.participants = new ArrayList<Participant>();
         this.variables = new HashMap<Class<?>, Object>();
         this.deadLine = (timeOutInMs > 0) ? System.currentTimeMillis() + timeOutInMs :
0;
-
-        this.holderRef = new WeakReference<CoordinationHolder>(new CoordinationHolder(this));
+        holder.setCoordination(this);
+        this.holderRef = new WeakReference<CoordinationHolder>(holder);
 
         scheduleTimeout(deadLine);
     }

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java?rev=1712478&r1=1712477&r2=1712478&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
Wed Nov  4 06:43:34 2015
@@ -42,6 +42,11 @@ import org.osgi.service.coordinator.Part
  */
 public class CoordinationMgr
 {
+    public static final class CreationResult 
+    {
+        public CoordinationImpl coordination;
+        public CoordinationHolder holder;
+    }
 
     private ThreadLocal<Stack<CoordinationImpl>> perThreadStack;
 
@@ -190,15 +195,15 @@ public class CoordinationMgr
 
     // ---------- Coordinator back end implementation
 
-    CoordinationImpl create(final CoordinatorImpl owner, final String name, final long timeout)
+    CreationResult create(final CoordinatorImpl owner, final String name, final long timeout)
     {
         final long id = ctr.incrementAndGet();
-        final CoordinationImpl c = new CoordinationImpl(owner, id, name, timeout);
+        final CreationResult result = CoordinationImpl.create(owner, id, name, timeout);
         synchronized ( this.coordinations )
         {
-            coordinations.put(id, c);
+            coordinations.put(id, result.coordination);
         }
-        return c;
+        return result;
     }
 
     void unregister(final CoordinationImpl c, final boolean removeFromThread)

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java?rev=1712478&r1=1712477&r2=1712478&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
Wed Nov  4 06:43:34 2015
@@ -151,9 +151,9 @@ public class CoordinatorImpl implements
     	}
 
     	// create coordination
-        final CoordinationImpl c = mgr.create(this, name, timeout);
+        final CoordinationMgr.CreationResult result = mgr.create(this, name, timeout);
 
-        return c.getHolder();
+        return result.holder;
     }
 
     /**
@@ -218,9 +218,9 @@ public class CoordinatorImpl implements
         }
 
         // create coordination
-        final CoordinationImpl c = mgr.create(this, name, timeout);
-        this.mgr.push(c);
-        return c.getHolder();
+        final CoordinationMgr.CreationResult result  = mgr.create(this, name, timeout);
+        this.mgr.push(result.coordination);
+        return result.holder;
     }
 
     /**



Mime
View raw message