[ https://issues.apache.org/jira/browse/FELIX-5436?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre De Rop resolved FELIX-5436. ---------------------------------- Resolution: Fixed Hi Jeroen; I committed the patch in revision 1772584. and slightly modified it in order to reuse the "callbackFound" variable, which I have reset to true in case an invocation target occurs. Also, I think the other exceptions (IllegalArgumentException , or IllegalAccessException) can be considered as a callback not found. thank you > Log message 'callback not found on component instances' incorrectly shown if > exception occurs during calling of callback method > ------------------------------------------------------------------------------------------------------------------------------- > > Key: FELIX-5436 > URL: https://issues.apache.org/jira/browse/FELIX-5436 > Project: Felix > Issue Type: Bug > Components: Dependency Manager > Affects Versions: org.apache.felix.dependencymanager-r8 > Reporter: Jeroen Daanen > Assignee: Pierre De Rop > Priority: Minor > > In the method ComponentImpl.invokeCallbackMethod(Object[], String, > Class<?>[][], Object[][], boolean) a message is logged when an exception > occurs during call of the callback method, because in that case the > 'callbackFound' variable is not set. > This is confusing when reading error log. > Suggestion for code change: > {code} > public void invokeCallbackMethod(Object[] instances, String methodName, > Class<?>[][] signatures, > Object[][] parameters, boolean logIfNotFound) { > boolean callbackFound = false; > boolean exceptionOccurredInCallback = false; > for (int i = 0; i < instances.length; i++) { > try { > InvocationUtil.invokeCallbackMethod(instances[i], methodName, > signatures, parameters); > callbackFound |= true; > } > catch (NoSuchMethodException e) { > // if the method does not exist, ignore it > } > catch (InvocationTargetException e) { > // the method itself threw an exception, log that > m_logger.log(Logger.LOG_ERROR, "Invocation of '" + methodName > + "' failed.", e.getCause()); > exceptionOccurredInCallback = true; > } > catch (Throwable e) { > m_logger.log(Logger.LOG_ERROR, "Could not invoke '" + > methodName + "'.", e); > exceptionOccurredInCallback = true; > } > } > > // If the callback is not found, we don't log if the method is on an > AbstractDecorator. > // (Aspect or Adapter are not interested in user dependency > callbacks) > if (logIfNotFound && ! exceptionOccurredInCallback && ! callbackFound > && ! (getInstance() instanceof AbstractDecorator)) { > if (m_logger == null) { > System.out.println("\"" + methodName + "\" callback not found > on component instances " > + Arrays.toString(instances)); > } else { > m_logger.log(LogService.LOG_ERROR, "\"" + methodName + "\" > callback not found on component instances " > + Arrays.toString(instances)); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)