chore: Log when service fails to instantiate#496
chore: Log when service fails to instantiate#496hypr2771 wants to merge 2 commits intoapache:masterfrom
Conversation
|
please look the ci jobs |
Missing `return` statement
Done, sorry for the silly mistake. |
|
Can you provide the complete stacktrace of the error? My concern with the change is that it no longer is re-throwing the error. What I expect to happen here is that the service factory SCR registers with the framework should throw this exception out and the OSGi framework implementation should capture the exception and fire a Framework error event. Then the log service should be logging the framework error event exception for you to observe. But now exception is caught and logged (that is fine), but then the exception is swallowed and not handled by the framework. |
You are right, it might break the propagation. We could just rethrow the exception if required. Reading each method to the exception, I noticed the Anyway, as requested, here is the full stack trace: View the full exception stack traceI think we loose the trace here: <S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isServiceObjetcs)
{
try
{
return m_registry.getService(bundle, ref, isServiceObjetcs);
}
catch (ServiceException ex)
{
fireFrameworkEvent(FrameworkEvent.ERROR, bundle, ex);
}
return null;
} |
|
I'm not familiar with the felix framework implementation, but if I follow correctly the implementation wrapped the causing exception in a If you have a log service bundle installed that should have mapped the framework event ERROR to a log entry as described at: https://docs.osgi.org/specification/osgi.core/8.0.0/service.log.html#d0e54935 and you should have been able to observe the error from the log service. That would be roughly equivalent to the ERROR log being proposed in this PR I think. |
I didn't answer your question. My point is that I don't believe we need to change anything in SCR to handle this error. Instead, we should continue to let it be thrown and handled by the framework as a framework event ERROR. |
Context
Had the following issue during my switch from Jackson 2 to 3:
It was really not straightforward to debug due to the lack of logging on the
org.apache.felix.scr.impl.manager.SingleComponentManager#getService(Bundle, ServiceRegistration<S>)method, and particularly since it caches the result.View an example stack trace
Goal
The goal of this PR is simply to add a log to let user know when a failure occurs and why, so that he can be aware something wrong occurred and can know the reason behind the linkage issue.