You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/06/26 05:32:36 UTC

karaf git commit: [KARAF-3798] Use a single threaded executor for FeaturesService prevents potential concurrent installations, each provision is queued on a single executor thread.

Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 5b88c52a5 -> 7f772d2ec


[KARAF-3798] Use a single threaded executor for FeaturesService prevents potential concurrent installations, each provision is queued on a single executor thread.


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/7f772d2e
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/7f772d2e
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/7f772d2e

Branch: refs/heads/karaf-4.0.x
Commit: 7f772d2ec8f2ebc49ff56d4c584f8dacd37cbe10
Parents: 5b88c52
Author: Fabian Lange <la...@gmail.com>
Authored: Tue Jan 26 22:56:04 2016 +0100
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Sat Jun 25 07:57:32 2016 +0200

----------------------------------------------------------------------
 .../apache/karaf/features/internal/osgi/Activator.java   |  1 +
 .../features/internal/service/FeaturesServiceImpl.java   | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/7f772d2e/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
index ec6a85c..d80a90b 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
@@ -275,6 +275,7 @@ public class Activator extends BaseActivator {
         }
         super.doStop();
         if (featuresService != null) {
+            featuresService.stop();
             featuresService = null;
         }
         if (digraph != null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/7f772d2e/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index f3707f1..149311e 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -180,6 +180,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
     private final Object lock = new Object();
     private final State state = new State();
     private final Map<String, Repository> repositoryCache = new HashMap<>();
+    private final ExecutorService executor;
     private Map<String, Map<String, Feature>> featureCache;
 
     public FeaturesServiceImpl(Bundle bundle,
@@ -220,6 +221,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         this.scheduleMaxRun = scheduleMaxRun;
         this.blacklisted = blacklisted;
         this.configCfgStore = FeaturesService.DEFAULT_CONFIG_CFG_STORE;
+        this.executor = Executors.newSingleThreadExecutor();
         loadState();
         checkResolve();
     }
@@ -263,6 +265,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         this.scheduleMaxRun = scheduleMaxRun;
         this.blacklisted = blacklisted;
         this.configCfgStore = configCfgStore;
+        this.executor = Executors.newSingleThreadExecutor();
         loadState();
         checkResolve();
     }
@@ -270,6 +273,11 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
     @SuppressWarnings({
      "unchecked", "rawtypes"
     })
+    public void stop() {
+      this.executor.shutdown();
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private void checkResolve() {
         if (bundle == null) {
             return; // Most certainly in unit tests
@@ -1052,7 +1060,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                                     final Map<String, Map<String, FeatureState>> stateChanges,
                                     final State state,
                                     final EnumSet<Option> options) throws Exception {
-        ExecutorService executor = Executors.newCachedThreadPool();
         try {
             final String outputFile = this.outputFile.get();
             this.outputFile.set(null);
@@ -1074,8 +1081,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             } else {
                 throw e;
             }
-        } finally {
-            executor.shutdown();
         }
     }