Uploaded image for project: 'Pax Exam'
  1. Pax Exam
  2. PAXEXAM-292

Using @inject annotation on ConfigurationAdmin produces a nullpointer exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0.M1, 2.4.0.RC1, 2.4.0
    • Fix Version/s: 2.4.0.RC1, 2.5.0
    • Component/s: Core
    • Labels:
      None

      Description

      If you inject a config admin in your unit test and execute getConfiguration("someValidKeyHere"); afterwards you end up in a nullpointer exception because the bundle in the config admin is null.

        Gliffy Diagrams

          Activity

          Hide
          hwellmann Harald Wellmann added a comment -

          I don't fully understand your problem description. I just wrote a regression test for ConfigurationAdmin (see GitHub tab on this ticket) and I don't see anything unusual.

          Can you extend the test case to expose your issue?

          Show
          hwellmann Harald Wellmann added a comment - I don't fully understand your problem description. I just wrote a regression test for ConfigurationAdmin (see GitHub tab on this ticket) and I don't see anything unusual. Can you extend the test case to expose your issue?
          Hide
          hwellmann Harald Wellmann added a comment -

          Possible cause:

          Make sure you use @javax.inject.Inject instead of Pax Exam's own Inject annotation.

          Show
          hwellmann Harald Wellmann added a comment - Possible cause: Make sure you use @javax.inject.Inject instead of Pax Exam's own Inject annotation.
          Hide
          marcel.hanser@nanohome.de Marcel Hanser added a comment -

          The issue is more complicated as thought.
          I'm going to attach a sample pax exam project for reproduction.

          The root of the problem is that pax exam closes the ServiceTracker in the ServiceLookup class. Since that invocation ungets the services on default, see
          the method org.osgi.util.tracker.ServiceTracker.removedService(ServiceReference, Object) (line 486)
          within the ServiceTracker implementation.
          The configuration admin of felix then disposes the service instance. See here
          org.apache.felix.cm.impl.ConfigurationAdminFactory.ungetService(Bundle, ServiceRegistration, Object) (line 61)

          The implementation of the ConfigurationAdmin of felix seems correct to me since the ConfigurationAdmin service is explicitly ungetted and should be disposed as done. I guess the correct solution is to remove the finally block which closes the service tracker.

          Show
          marcel.hanser@nanohome.de Marcel Hanser added a comment - The issue is more complicated as thought. I'm going to attach a sample pax exam project for reproduction. The root of the problem is that pax exam closes the ServiceTracker in the ServiceLookup class. Since that invocation ungets the services on default, see the method org.osgi.util.tracker.ServiceTracker.removedService(ServiceReference, Object) (line 486) within the ServiceTracker implementation. The configuration admin of felix then disposes the service instance. See here org.apache.felix.cm.impl.ConfigurationAdminFactory.ungetService(Bundle, ServiceRegistration, Object) (line 61) The implementation of the ConfigurationAdmin of felix seems correct to me since the ConfigurationAdmin service is explicitly ungetted and should be disposed as done. I guess the correct solution is to remove the finally block which closes the service tracker.
          Hide
          marcel.hanser@nanohome.de Marcel Hanser added a comment -

          For reproduction.
          The codeline above of the org.apache.felix.cm.impl.ConfigurationAdminFactory is from version 1.2.8, sry

          Show
          marcel.hanser@nanohome.de Marcel Hanser added a comment - For reproduction. The codeline above of the org.apache.felix.cm.impl.ConfigurationAdminFactory is from version 1.2.8, sry
          Hide
          tnarake Timo Naroska added a comment -

          The ServiceLookup facility was moved to pax-swissbox. See PAXSB-54

          Show
          tnarake Timo Naroska added a comment - The ServiceLookup facility was moved to pax-swissbox. See PAXSB-54
          Hide
          hwellmann Harald Wellmann added a comment -

          Likely to be fixed with upgrade to Pax Swissbox 1.5.1, see PAXEXAM-406, PAXEXAM-410.

          Show
          hwellmann Harald Wellmann added a comment - Likely to be fixed with upgrade to Pax Swissbox 1.5.1, see PAXEXAM-406 , PAXEXAM-410 .

            People

            • Assignee:
              hwellmann Harald Wellmann
              Reporter:
              anpieber Andreas Pieber
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development