Thomas Watson created ARIES-971:
-----------------------------------

             Summary: ServiceHelper.CacheClearoutListener.add(BundleContext, 
ServiceKey) causes NPE if system bundle is hidden
                 Key: ARIES-971
                 URL: https://issues.apache.org/jira/browse/ARIES-971
             Project: Aries
          Issue Type: Bug
          Components: JNDI
         Environment: All
            Reporter: Thomas Watson


In 
org.apache.aries.jndi.services.ServiceHelper.CacheClearoutListener.add(BundleContext,
 ServiceKey) the following code will cause an NPE:

 // try to use the system bundle for our listener, 
 // if that fails we fall back to the calling context
 BundleContext systemBundle = 
   AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
   public BundleContext run()
   {
     return ctx.getBundle(0).getBundleContext(); <<< NPE here
   }
 });

This can happen if a bundle FindHook hides the bundle 0 from the ctx bundle.  A 
check for null should be done here:

 BundleContext systemBundle = 
   AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
   public BundleContext run()
   {
     Bundle system = ctx.getBundle(0);
     return system == null ? null : system.getBundleContext();
   }
 });


This would allow jndi to work in such environments where bundle, service, and 
resolver hooks are used for isolation (e.g. subsystems).

--
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