Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-2813

NPE in UpdateThread when updating a configuration right after ConfigurationAdmin service starts

    XMLWordPrintableJSON

Details

    Description

      When you:
      1) register as a configuration listener
      2) wait for the ConfigurationAdmin service to start
      3) upon start, immediately create a new configuration and update its properties

      You (sometimes) get a NPE in the UpdateThread because there is a race condition in the codebase:
      a) ConfigurationManager.java:1818 will invoke getServiceReference() which uses the service registration to get to the reference
      b) ConfigurationManager.java:242 registers the service and assigns the registration to 'configurationAdminRegistration'

      First of all, the call to registerService in line 242 will already trigger service listeners and trackers to invoke callbacks before this call returns, so 'configurationAdminRegistration' will still be null. Furthermore, there is no synchronization, the member is not volatile, so we need to make sure this value is really written before any configuration events are created under a) (now the thread doing that is started way before the service is registered).

      I will commit a test that shows the exception, but since it happens in a thread I cannot "catch" it won't show up as a failed test.

      Attachments

        Issue Links

          Activity

            People

              fmeschbe Felix Meschberger
              marrs Marcel Offermans
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: