felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1452071 - /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
Date Sun, 03 Mar 2013 17:35:10 GMT
Author: clement
Date: Sun Mar  3 17:35:10 2013
New Revision: 1452071

URL: http://svn.apache.org/r1452071
Log:
Fix FELIX-3896.

Check for null before calling the bind callback. If the service object is null, we remove
the service binding associated to this reference.

Modified:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java?rev=1452071&r1=1452070&r2=1452071&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
Sun Mar  3 17:35:10 2013
@@ -277,11 +277,25 @@ public class Dependency extends Dependen
             if (m_callbacks[j].getMethodType() == DependencyCallback.BIND) {
                 if (isAggregate()) {
                     for (int i = 0; i < refs.length; i++) {
-                        invokeCallback(m_callbacks[j], refs[i], getService(refs[i]), pojo);
+                        Object svc = getService(refs[i]);
+                        if (svc != null) {
+                            invokeCallback(m_callbacks[j], refs[i], svc, pojo);
+                        } else {
+                            // The service left already, or the service object cannot be
created.
+                            // We consider it as a departure.
+                            removedService(refs[i],  null);
+                        }
                     }
                 } else {
                     // Take the first reference.
-                    invokeCallback(m_callbacks[j], refs[0], getService(refs[0]), pojo);
+                    Object svc = getService(refs[0]);
+                    if (svc != null) {
+                        invokeCallback(m_callbacks[j], refs[0], svc, pojo);
+                    } else {
+                        // The service left already, or the service object cannot be created.
+                        // We consider it as a departure.
+                        removedService(refs[0],  null);
+                    }
                 }
             }
         }
@@ -353,7 +367,16 @@ public class Dependency extends Dependen
         if (m_handler.getInstanceManager().getState() > InstanceManager.STOPPED &&
m_handler.getInstanceManager().getPojoObjects() != null) {
             for (int i = 0; m_callbacks != null && i < m_callbacks.length; i++)
{
                 if (m_callbacks[i].getMethodType() == DependencyCallback.BIND) {
-                    invokeCallback(m_callbacks[i], ref, getService(ref), null);
+                    Object svc = getService(ref);
+                    System.out.println("Svc injected in the bind method : " + svc);
+                    if (svc != null) {
+                        invokeCallback(m_callbacks[i], ref, svc, null);
+                    } else {
+                        // We can't get the service object (https://issues.apache.org/jira/browse/FELIX-3896).
+                        // This is probably because the service is leaving.
+                        // We consider it as a departure.
+                        removedService(ref, null);
+                    }
                 }
             }
         }



Mime
View raw message