You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2017/09/15 09:41:47 UTC

[1/5] karaf git commit: Optimize string operations

Repository: karaf
Updated Branches:
  refs/heads/master e4ccd2c39 -> cf651678c


Optimize string operations


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

Branch: refs/heads/master
Commit: 02350ad10ffb5972dd416f722eec33509defddb5
Parents: 4dbc729
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Sep 15 08:01:25 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Sep 15 08:01:25 2017 +0200

----------------------------------------------------------------------
 .../org/apache/karaf/features/internal/model/Feature.java   | 8 ++++----
 .../apache/karaf/features/internal/region/Subsystem.java    | 2 +-
 .../features/internal/service/FeaturesServiceImpl.java      | 9 +++++----
 3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java b/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
index 752d2a8..9e838e6 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
@@ -127,10 +127,10 @@ public class Feature extends Content implements org.apache.karaf.features.Featur
     }
 
     public static org.apache.karaf.features.Feature valueOf(String str) {
-        if (str.contains(VERSION_SEPARATOR)) {
-            String strName = str.substring(0, str.indexOf(VERSION_SEPARATOR));
-            String strVersion = str.substring(str.indexOf(VERSION_SEPARATOR)
-                    + VERSION_SEPARATOR.length(), str.length());
+        int idx = str.indexOf(VERSION_SEPARATOR);
+        if (idx >= 0) {
+            String strName = str.substring(0, idx);
+            String strVersion = str.substring(idx + VERSION_SEPARATOR.length(), str.length());
             return new Feature(strName, strVersion);
         } else {
             return new Feature(str);

http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
index 88b4412..33b9dae 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
@@ -227,7 +227,7 @@ public class Subsystem extends ResourceImpl {
     }
 
     public void require(String requirement) throws BundleException {
-        int idx = requirement.indexOf(":");
+        int idx = requirement.indexOf(':');
         String type, req;
         if (idx >= 0) {
             type = requirement.substring(0, idx);

http://git-wip-us.apache.org/repos/asf/karaf/blob/02350ad1/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 c1e7b0c..932fd41 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
@@ -82,6 +82,8 @@ import org.slf4j.LoggerFactory;
 
 import static java.util.Collections.emptyMap;
 import static java.util.stream.Collectors.toSet;
+import static org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION;
+import static org.apache.karaf.features.internal.model.Feature.VERSION_SEPARATOR;
 import static org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap;
 import static org.apache.karaf.features.internal.util.MapUtils.*;
 
@@ -92,7 +94,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
 
     private static final String RESOLVE_FILE = "resolve";
     private static final Logger LOGGER = LoggerFactory.getLogger(FeaturesServiceImpl.class);
-    private static final String VERSION_SEPARATOR = "/";
 
     /**
      * Used to load and save the {@link State} of this service.
@@ -893,10 +894,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
     }
 
     private String normalize(String feature) {
-        if (!feature.contains(VERSION_SEPARATOR)) {
-            feature += "/0.0.0";
-        }
         int idx = feature.indexOf(VERSION_SEPARATOR);
+        if (idx < 0) {
+            return feature + VERSION_SEPARATOR + DEFAULT_VERSION;
+        }
         String name = feature.substring(0, idx);
         String version = feature.substring(idx + 1);
         return name + VERSION_SEPARATOR + VersionCleaner.clean(version);


[3/5] karaf git commit: [KARAF-5375] Add a unit test

Posted by gn...@apache.org.
[KARAF-5375] Add a unit test


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

Branch: refs/heads/master
Commit: b4875d651db6411c7787bd0c536c18c74f1d0bee
Parents: e430d25
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Sep 15 10:49:08 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Sep 15 11:25:41 2017 +0200

----------------------------------------------------------------------
 .../internal/download/DownloadManager.java      |  5 +-
 .../download/impl/MavenDownloadManager.java     |  5 ++
 .../features/internal/service/Deployer.java     | 16 +----
 .../internal/service/FeaturesServiceConfig.java |  4 +-
 .../internal/service/FeaturesServiceImpl.java   | 18 ++---
 .../service/FeaturesServiceImplTest.java        | 76 +++++++++++++++++++-
 6 files changed, 99 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/features/core/src/main/java/org/apache/karaf/features/internal/download/DownloadManager.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/download/DownloadManager.java b/features/core/src/main/java/org/apache/karaf/features/internal/download/DownloadManager.java
index d9094a1..0893c90 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/download/DownloadManager.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/download/DownloadManager.java
@@ -18,10 +18,13 @@ package org.apache.karaf.features.internal.download;
 
 import java.util.Map;
 
-public interface DownloadManager {
+public interface DownloadManager extends AutoCloseable {
 
     Downloader createDownloader();
 
     Map<String, StreamProvider> getProviders();
 
+    default void close() {
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadManager.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadManager.java b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadManager.java
index 65f798b..ede3337 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadManager.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadManager.java
@@ -80,6 +80,11 @@ public class MavenDownloadManager implements DownloadManager {
         return (Map) Collections.synchronizedMap(downloaded);
     }
 
+    @Override
+    public void close() {
+        executorService.shutdown();
+    }
+
     protected class MavenDownloader implements Downloader {
 
         private volatile int pending = 0;

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index 0e29e2c..e2c3522 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -1101,22 +1101,12 @@ public class Deployer {
     }
 
     private static void removeFragmentsAndBundlesInState(Collection<Bundle> bundles, int state) {
-        for (Iterator<Bundle> iterator = bundles.iterator(); iterator.hasNext();) {
-            Bundle bundle = iterator.next();
-            if ((bundle.getState() & state) != 0
-                    || bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) {
-                iterator.remove();
-            }
-        }
+        bundles.removeIf(bundle -> (bundle.getState() & state) != 0
+                || bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null);
     }
 
     private static void removeBundlesInState(Collection<Bundle> bundles, int state) {
-        for (Iterator<Bundle> iterator = bundles.iterator(); iterator.hasNext();) {
-            Bundle bundle = iterator.next();
-            if ((bundle.getState() & state) != 0) {
-                iterator.remove();
-            }
-        }
+        bundles.removeIf(bundle -> (bundle.getState() & state) != 0);
     }
 
     protected void logWiring(Map<Resource, List<Wire>> wiring, boolean onlyFeatures) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java
index 68f957c..f6fe033 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java
@@ -16,6 +16,8 @@
  */
 package org.apache.karaf.features.internal.service;
 
+import org.apache.karaf.features.FeaturesService;
+
 public class FeaturesServiceConfig {
 
     public final String overrides;
@@ -56,7 +58,7 @@ public class FeaturesServiceConfig {
     public final String blacklisted;
 
     public FeaturesServiceConfig() {
-        this(null, null, null, null, 1, 0, 0, null, null);
+        this(null, FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, FeaturesService.DEFAULT_BUNDLE_UPDATE_RANGE, null, 1, 0, 0, null, null);
     }
 
     public FeaturesServiceConfig(String overrides, String featureResolutionRange, String bundleUpdateRange, String updateSnapshots, int downloadThreads, long scheduleDelay, int scheduleMaxRun, String blacklisted, String serviceRequirements) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/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 c1e7b0c..e07d9db 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
@@ -978,13 +978,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                              EnumSet<Option> options,                              // installation options
                              String outputFile                                     // file to store the resolution or null
     ) throws Exception {
-
-        Dictionary<String, String> props = getMavenConfig();
-        MavenResolver resolver = MavenResolvers.createMavenResolver(props, "org.ops4j.pax.url.mvn");
-        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(cfg.downloadThreads);
-        executor.setMaximumPoolSize(cfg.downloadThreads);
-        DownloadManager manager = DownloadManagers.createDownloadManager(resolver, executor, cfg.scheduleDelay, cfg.scheduleMaxRun);
-        try {
+        try (DownloadManager manager = createDownloadManager()) {
             Set<String> prereqs = new HashSet<>();
             while (true) {
                 try {
@@ -1001,11 +995,17 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                     }
                 }
             }
-        } finally {
-            executor.shutdown();
         }
     }
 
+    protected DownloadManager createDownloadManager() throws IOException {
+        Dictionary<String, String> props = getMavenConfig();
+        MavenResolver resolver = MavenResolvers.createMavenResolver(props, "org.ops4j.pax.url.mvn");
+        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(cfg.downloadThreads);
+        executor.setMaximumPoolSize(cfg.downloadThreads);
+        return DownloadManagers.createDownloadManager(resolver, executor, cfg.scheduleDelay, cfg.scheduleMaxRun);
+    }
+
     private Dictionary<String, String> getMavenConfig() throws IOException {
         Hashtable<String, String> props = new Hashtable<>();
         if (configurationAdmin != null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4875d65/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
index f5363d4..c351ad7 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesServiceImplTest.java
@@ -22,25 +22,38 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.net.*;
+import java.util.Collections;
 import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Map;
 
 import org.apache.felix.resolver.ResolverImpl;
 import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeatureState;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.TestBase;
 import org.apache.karaf.features.FeaturesService.Option;
+import org.apache.karaf.features.internal.download.DownloadManager;
 import org.apache.karaf.features.internal.resolver.Slf4jResolverLog;
 import org.apache.karaf.features.internal.service.BundleInstallSupport.FrameworkInfo;
+import org.apache.karaf.features.internal.support.TestDownloadManager;
+import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+import org.osgi.framework.startlevel.BundleStartLevel;
+import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.service.resolver.Resolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -162,7 +175,68 @@ public class FeaturesServiceImplTest extends TestBase {
         waitInstalled(featureService, test110);
         assertNotInstalled(featureService, test100);
     }
-    
+
+    @Test
+    public void testInstallAndStop() throws Exception {
+        Capture<Bundle> stoppedBundle = Capture.newInstance();
+
+        Bundle bundle = EasyMock.niceMock(Bundle.class);
+        BundleStartLevel bundleStartLevel = EasyMock.niceMock(BundleStartLevel.class);
+        BundleRevision bundleRevision = EasyMock.niceMock(BundleRevision.class);
+
+        FeaturesServiceConfig cfg = new FeaturesServiceConfig();
+        BundleInstallSupport installSupport = EasyMock.niceMock(BundleInstallSupport.class);
+        FrameworkInfo dummyInfo = new FrameworkInfo();
+        expect(installSupport.getInfo()).andReturn(dummyInfo).atLeastOnce();
+        expect(installSupport.installBundle(EasyMock.eq("root"), EasyMock.eq("a100"), anyObject())).andReturn(bundle);
+        installSupport.startBundle(bundle);
+        expectLastCall();
+        expect(bundle.getBundleId()).andReturn(1L).anyTimes();
+        expect(bundle.getSymbolicName()).andReturn("a").anyTimes();
+        expect(bundle.getVersion()).andReturn(new Version("1.0.0")).anyTimes();
+        expect(bundle.getHeaders()).andReturn(new Hashtable<>()).anyTimes();
+        expect(bundle.adapt(BundleStartLevel.class)).andReturn(bundleStartLevel).anyTimes();
+        expect(bundle.adapt(BundleRevision.class)).andReturn(bundleRevision).anyTimes();
+        expect(bundleRevision.getBundle()).andReturn(bundle).anyTimes();
+        expect(bundleRevision.getCapabilities(null)).andReturn(Collections.emptyList()).anyTimes();
+        expect(bundleRevision.getRequirements(null)).andReturn(Collections.emptyList()).anyTimes();
+        EasyMock.replay(installSupport, bundle, bundleStartLevel, bundleRevision);
+        FeaturesService featureService =  new FeaturesServiceImpl(new Storage(), null, null, this.resolver,
+                installSupport, null, cfg) {
+            @Override
+            protected DownloadManager createDownloadManager() throws IOException {
+                return new TestDownloadManager(FeaturesServiceImplTest.class, "data1");
+            }
+        };
+
+        URI repoA = URI.create("custom:data1/features.xml");
+        featureService.addRepository(repoA);
+        Feature test100 = featureService.getFeature("f", "1.0.0");
+        installFeature(featureService, test100);
+        assertInstalled(featureService, test100);
+
+        dummyInfo.bundles.put(1L, bundle);
+        Map<String, Map<String, FeatureState>> states = new HashMap<>();
+        states.computeIfAbsent("root", k -> new HashMap<>()).put("f/1.0.0", FeatureState.Resolved);
+        EasyMock.reset(installSupport, bundle, bundleRevision, bundleStartLevel);
+        expect(installSupport.getInfo()).andReturn(dummyInfo).anyTimes();
+        installSupport.stopBundle(EasyMock.capture(stoppedBundle), EasyMock.anyInt());
+        expectLastCall();
+        expect(bundle.getBundleId()).andReturn(1L).anyTimes();
+        expect(bundle.getSymbolicName()).andReturn("a").anyTimes();
+        expect(bundle.getVersion()).andReturn(new Version("1.0.0")).anyTimes();
+        expect(bundle.getHeaders()).andReturn(new Hashtable<>()).anyTimes();
+        expect(bundle.adapt(BundleStartLevel.class)).andReturn(bundleStartLevel).anyTimes();
+        expect(bundle.adapt(BundleRevision.class)).andReturn(bundleRevision).anyTimes();
+        expect(bundleRevision.getBundle()).andReturn(bundle).anyTimes();
+        expect(bundleRevision.getCapabilities(null)).andReturn(Collections.emptyList()).anyTimes();
+        expect(bundleRevision.getRequirements(null)).andReturn(Collections.emptyList()).anyTimes();
+        EasyMock.replay(installSupport, bundle, bundleRevision, bundleStartLevel);
+
+        featureService.updateFeaturesState(states, EnumSet.noneOf(Option.class));
+        assertSame(bundle, stoppedBundle.getValue());
+    }
+
     @Test
     public void testRemoveRepo2() throws Exception {
         final FeaturesService featureService = createTestFeatureService();


[4/5] karaf git commit: Merge branch 'KARAF-5375', fixes #371

Posted by gn...@apache.org.
Merge branch 'KARAF-5375', fixes #371


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

Branch: refs/heads/master
Commit: 644e3b93792b6caa4368aebd0b62dda5e63e83e2
Parents: e4ccd2c b4875d6
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Sep 15 11:26:17 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Sep 15 11:26:17 2017 +0200

----------------------------------------------------------------------
 .../internal/download/DownloadManager.java      |  5 +-
 .../download/impl/MavenDownloadManager.java     |  5 ++
 .../features/internal/service/Deployer.java     | 16 +----
 .../internal/service/FeaturesServiceConfig.java |  4 +-
 .../internal/service/FeaturesServiceImpl.java   | 18 ++---
 .../service/FeaturesServiceImplTest.java        | 76 +++++++++++++++++++-
 6 files changed, 99 insertions(+), 25 deletions(-)
----------------------------------------------------------------------



[5/5] karaf git commit: Merge branch 'optimizations', fixes #367, #368, #370

Posted by gn...@apache.org.
Merge branch 'optimizations', fixes #367, #368, #370


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

Branch: refs/heads/master
Commit: cf651678c5531445ae54cca0461f939321e26d7a
Parents: 644e3b9 9b37038
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Sep 15 11:27:18 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Sep 15 11:27:18 2017 +0200

----------------------------------------------------------------------
 .../karaf/features/internal/model/Feature.java    |  8 ++++----
 .../karaf/features/internal/region/Subsystem.java |  2 +-
 .../internal/service/FeaturesServiceImpl.java     | 18 +++++++-----------
 3 files changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/cf651678/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------


[2/5] karaf git commit: Optimize using Map#computeIfAbstent

Posted by gn...@apache.org.
Optimize using Map#computeIfAbstent


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

Branch: refs/heads/master
Commit: 9b37038fd3f8e3b87576e16aca3a76a9baa577eb
Parents: 02350ad
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Sep 15 08:01:41 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Sep 15 08:01:41 2017 +0200

----------------------------------------------------------------------
 .../features/internal/service/FeaturesServiceImpl.java      | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9b37038f/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 932fd41..9848bca 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
@@ -579,13 +579,8 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         // * then load all features
         for (Repository repo : repos) {
             for (Feature f : repo.getFeatures()) {
-                if (map.get(f.getName()) == null) {
-                    Map<String, Feature> versionMap = new HashMap<>();
-                    versionMap.put(f.getVersion(), f);
-                    map.put(f.getName(), versionMap);
-                } else {
-                    map.get(f.getName()).put(f.getVersion(), f);
-                }
+                Map<String, Feature> versionMap = map.computeIfAbsent(f.getName(), key -> new HashMap<>());
+                versionMap.put(f.getVersion(), f);
             }
         }
         synchronized (lock) {