Amichai Rothman created DOSGI-164:
-------------------------------------

             Summary: NullPointerException on export
                 Key: DOSGI-164
                 URL: https://issues.apache.org/jira/browse/DOSGI-164
             Project: CXF Distributed OSGi
          Issue Type: Bug
          Components: DSW
    Affects Versions: 1.4.0
         Environment: Oracle JDK 1.7.0_17, Karaf 2.3.1, DOSGi 1.4.0
            Reporter: Amichai Rothman


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)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to