Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-6074

Race condition between the FeaturesService and FeatureDeploymentListener

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 4.2.2, 4.2.4
    • 4.4.4, 4.3.10
    • karaf
    • None
    • Karaf 4.2.2 Windows 7 and Equinox

    Description

      On the first start of a custom Karaf container (4.2.2), the logs shows a log of NPE in FeatureDeploymentListener.

      After some analysis of this Exception, it's look like a race condition between the FeaturesService and the FeatureDeploymentListener :

      1. The FeaturesService starts and launch a provisioning in another thread
      2. a FeatureDeploymentListener is registered, and call bundleChanged for every bundle installed (the startup bundles)
      3. It calls FeaturesService.state.requirements and get an empty map
      4. Updating the root regions in the requirements map fails with an NPE
      5. Some times later, the deployment task launched at step 1 is started, and FeaturesService.saveState() is called : state.requirements."root region" is initialised

      The step 5 is executed in another thread, so it can happens before step 2 (and it works) or after, causing this NPE

      Moreover, some methods in FeaturesService assume that state.requirements."root region" exists. There are probably others npe here.

       

      14:37:55.668 ERROR [activator-1-thread-2] Unable to update deployed features for bundle: org.eclipse.osgi - 3.12.100.v20180210-1608
      java.lang.NullPointerException: null
      at org.apache.karaf.deployer.features.FeatureDeploymentListener.bundleChanged(FeatureDeploymentListener.java:247) [25:org.apache.karaf.deployer.features:4.2.2]
      at org.apache.karaf.deployer.features.FeatureDeploymentListener.init(FeatureDeploymentListener.java:95) [25:org.apache.karaf.deployer.features:4.2.2]
      at org.apache.karaf.deployer.features.osgi.Activator.doStart(Activator.java:52) [25:org.apache.karaf.deployer.features:4.2.2]
      at org.apache.karaf.util.tracker.BaseActivator.run(BaseActivator.java:292) [25:org.apache.karaf.deployer.features:4.2.2]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

      Attachments

        Issue Links

          Activity

            People

              jbonofre Jean-Baptiste Onofré
              j3rem1e J. Brébec
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: