Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-971

ServiceHelper.CacheClearoutListener.add(BundleContext, ServiceKey) causes NPE if system bundle is hidden

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • jndi-url-1.1.0
    • JNDI
    • None
    • All

    Description

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

      Attachments

        Activity

          People

            mnuttall Mark Nuttall
            tjwatson Tom Watson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: