Details
Description
I got the exception below in the Karaf console on two occasions, once when just starting up Karaf, and once when a bundle was re-deployed. It looks like it's caused by using the return value of ServiceReference.getBundle() without a null check (the method's docs explicitly states it must return null if the service is unregistered).
Note that this looks like the same cause as DOSGI-120 but in a different place in the code - and it can probably happen in other usages of ServiceReference.getBundle() which are missing a null check as well. BTW, the fix for DOSGI-120 is not entirely safe either, since it calls getBundle once for the null check, and again for using it, and the service state (and return value) might change in between the two - it's a race condition with an unregistering service. A better approach might be to call getBundle once, storing the result in a local variable, and then performing the null check and subsequently accessing the (unchanging) local variable.
Exception in thread "pool-16-thread-1" java.lang.NullPointerException
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore.exportService(RemoteServiceAdminCore.java:104)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:64)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:58)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:58)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:37)
at org.apache.cxf.dosgi.topologymanager.exporter.TopologyManagerExport.doExportService(TopologyManagerExport.java:249)
at org.apache.cxf.dosgi.topologymanager.exporter.TopologyManagerExport.access$300(TopologyManagerExport.java:50)
at org.apache.cxf.dosgi.topologymanager.exporter.TopologyManagerExport$3.run(TopologyManagerExport.java:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Attachments
Issue Links
- relates to
-
DOSGI-120 NullPointerException on export
- Closed