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 2019/11/26 13:47:17 UTC

[karaf] branch karaf-4.2.x updated: ensure bundle order is respected in startup.properties

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new 634aa5d  ensure bundle order is respected in startup.properties
634aa5d is described below

commit 634aa5da8837ec9399e48bd6ddf8f5d1c7e8ba99
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Tue Nov 26 14:34:30 2019 +0100

    ensure bundle order is respected in startup.properties
---
 .../src/main/java/org/apache/karaf/profile/assembly/Builder.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index f77cda4..ae59e1c 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -109,6 +109,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static java.util.Collections.singletonList;
+import static java.util.Comparator.comparing;
 import static java.util.jar.JarFile.MANIFEST_NAME;
 import static org.apache.karaf.profile.assembly.Builder.Stage.Startup;
 
@@ -1964,7 +1965,10 @@ public class Builder {
         Map<Integer, Set<String>> invertedStartupBundles = MapUtils.invert(bundles);
         for (Map.Entry<Integer, Set<String>> entry : new TreeMap<>(invertedStartupBundles).entrySet()) {
             String startLevel = Integer.toString(entry.getKey());
-            for (String location : new TreeSet<>(entry.getValue())) {
+            // ensure input order is respected whatever hashmap/set was in the middle of the processing
+            final List<String> value = new ArrayList<>(entry.getValue());
+            value.sort(comparing(bnd -> startupEffective.getBundles().indexOf(bnd)));
+            for (String location : value) {
                 if (useReferenceUrls) {
                     if (location.startsWith("mvn:")) {
                         location = "file:" + Parser.pathFromMaven(location);