Karaf
  1. Karaf
  2. KARAF-1797

NPE thrown from OsgiConfiguration.unregister

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.5
    • Fix Version/s: 2.2.10, 2.3.0, 3.0.0
    • Component/s: karaf-core
    • Labels:
      None

      Description

      Passing in a null value for "realm" to unregister causes:

      2012-09-06 09:35:00,700 | ERROR | -70-091-thread-1 | tServiceReferenceRecipe$Listener | 8 - org.apache.aries.blueprint - 0.3.1.fuse-70-091 | Error calling listener method public void org.apache.karaf.jaas.config.impl.OsgiConfiguration.unregister(org.apache.karaf.jaas.config.JaasRealm,java.util.Map)
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_33]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_33]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_33]
      at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_33]
      at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:284)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$Listener.invokeMethods(AbstractServiceReferenceRecipe.java:461)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$Listener.unbind(AbstractServiceReferenceRecipe.java:430)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.unbind(AbstractServiceReferenceRecipe.java:333)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.ReferenceListRecipe.untrack(ReferenceListRecipe.java:144)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceRemoved(AbstractServiceReferenceRecipe.java:275)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.access$200(AbstractServiceReferenceRecipe.java:64)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$1.run(AbstractServiceReferenceRecipe.java:245)[8:org.apache.aries.blueprint:0.3.1.fuse-70-091]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_33]
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_33]
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_33]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_33]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_33]
      at java.lang.Thread.run(Thread.java:680)[:1.6.0_33]
      Caused by: java.lang.NullPointerException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_33]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_33]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_33]
      at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_33]
      at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
      at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
      at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
      at $Proxy11.equals(Unknown Source)[13:org.apache.karaf.jaas.config:2.2.5.fuse-70-091]
      at java.util.concurrent.CopyOnWriteArrayList.eq(CopyOnWriteArrayList.java:131)[:1.6.0_33]
      at java.util.concurrent.CopyOnWriteArrayList.remove(CopyOnWriteArrayList.java:484)[:1.6.0_33]
      at org.apache.karaf.jaas.config.impl.OsgiConfiguration.unregister(OsgiConfiguration.java:48)[13:org.apache.karaf.jaas.config:2.2.5.fuse-70-091]
      ... 18 more

      However there's some valid cases for this if the service is optional and not available. In my case it appears to be happening as part of installing a second jaas module.

        Issue Links

          Activity

          Stan Lewis created issue -
          Hide
          Stan Lewis added a comment -

          Note that while this appears to mess up authentication in general, doing an osgi:update on the org.apache.karaf.jaas.config bundle will get authentication working again.

          Show
          Stan Lewis added a comment - Note that while this appears to mess up authentication in general, doing an osgi:update on the org.apache.karaf.jaas.config bundle will get authentication working again.
          Guillaume Nodet made changes -
          Field Original Value New Value
          Assignee Guillaume Nodet [ gnt ]
          Show
          Guillaume Nodet added a comment - URL: http://svn.apache.org/viewvc?rev=1381984&view=rev URL: http://svn.apache.org/viewvc?rev=1381989&view=rev URL: http://svn.apache.org/viewvc?rev=1381990&view=rev
          Guillaume Nodet made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.2.10 [ 12322541 ]
          Fix Version/s 2.3.0 [ 12320554 ]
          Fix Version/s 3.0.0 [ 12316040 ]
          Resolution Fixed [ 1 ]
          Hide
          Guillaume Nodet added a comment -

          The issue isn't really fixed

          Show
          Guillaume Nodet added a comment - The issue isn't really fixed
          Guillaume Nodet made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Guillaume Nodet added a comment -

          The real cause of the NPE is because the call to obtain the real service in the blueprint proxy can return null in some cases:

          https://github.com/apache/aries/blob/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java#L207

          This is because when the service is being unregistered, the reference inside the proxy will be valid, but the service not available. Given the above code does not check for the service returned not being null, we have this NPE. So this should be fixed in Blueprint.

          However, this also means that the equals method on proxies can't be used reliably, so proxies need to be wrapped into an object that will check Object equality on proxies rather than the proxied objects are equals.

          Show
          Guillaume Nodet added a comment - The real cause of the NPE is because the call to obtain the real service in the blueprint proxy can return null in some cases: https://github.com/apache/aries/blob/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceListRecipe.java#L207 This is because when the service is being unregistered, the reference inside the proxy will be valid, but the service not available. Given the above code does not check for the service returned not being null, we have this NPE. So this should be fixed in Blueprint. However, this also means that the equals method on proxies can't be used reliably, so proxies need to be wrapped into an object that will check Object equality on proxies rather than the proxied objects are equals.
          Guillaume Nodet made changes -
          Link This issue relates to ARIES-923 [ ARIES-923 ]
          Show
          Guillaume Nodet added a comment - URL: http://svn.apache.org/viewvc?rev=1382930&view=rev URL: http://svn.apache.org/viewvc?rev=1382962&view=rev URL: http://svn.apache.org/viewvc?rev=1383262&view=rev
          Guillaume Nodet made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          21h 48m 1 Guillaume Nodet 07/Sep/12 13:19
          Resolved Resolved Reopened Reopened
          2d 19h 47m 1 Guillaume Nodet 10/Sep/12 09:07
          Reopened Reopened Resolved Resolved
          23h 4m 1 Guillaume Nodet 11/Sep/12 08:12

            People

            • Assignee:
              Guillaume Nodet
              Reporter:
              Stan Lewis
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development