felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1730334 - /felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
Date Sun, 14 Feb 2016 13:21:59 GMT
Author: pderop
Date: Sun Feb 14 13:21:59 2016
New Revision: 1730334

URL: http://svn.apache.org/viewvc?rev=1730334&view=rev
Log:
FELIX-5188: No error log when a factory pid adapter update callback is not found.

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java?rev=1730334&r1=1730333&r2=1730334&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
Sun Feb 14 13:21:59 2016
@@ -19,9 +19,11 @@
 package org.apache.felix.dm.impl;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.stream.Stream;
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -172,9 +174,12 @@ public class FactoryConfigurationAdapter
         }
         
         private void invokeUpdated(Component service, CallbackTypeDef callbackInfo) {
-            for (Object instance : getUpdateCallbackInstances(service)) {
+            boolean callbackFound = false;
+            Object[] instances = getUpdateCallbackInstances(service);
+            for (Object instance : instances) {
                 try {
                     InvocationUtil.invokeCallbackMethod(instance, m_update, callbackInfo.m_sigs,
callbackInfo.m_args);
+                    callbackFound |= true;
                 }
                 catch (InvocationTargetException e) {
                     // The component has thrown an exception during it's callback invocation.
@@ -187,6 +192,11 @@ public class FactoryConfigurationAdapter
                     handleException(t); // will rethrow a runtime exception.
                 }
             }
+            
+            if (! callbackFound) {
+                String[] instanceClasses = Stream.of(instances).map(c -> c.getClass().getName()).toArray(String[]::new);
+                m_logger.log(Logger.LOG_ERROR, "\"" + m_update + "\" configuration callback
not found in any of the component classes: " + Arrays.toString(instanceClasses));        
           
+            }
         }
         
         /**
@@ -239,7 +249,11 @@ public class FactoryConfigurationAdapter
         }
 
         private void handleException(Throwable t) {
-            m_logger.log(Logger.LOG_ERROR, "Got exception while handling configuration update
for factory pid " + m_factoryPid, t);
+            if (m_logger != null) {
+                m_logger.log(Logger.LOG_ERROR, "Got exception while handling configuration
update for factory pid " + m_factoryPid, t);
+            } else {
+                
+            }
             if (t instanceof InvocationTargetException) {
                 // Our super class will check if the target exception is itself a ConfigurationException.
                 // In this case, it will simply re-thrown.



Mime
View raw message