diff --git a/src/main/java/org/apache/sling/feature/Artifact.java b/src/main/java/org/apache/sling/feature/Artifact.java index 4a73d20..32934ff 100644 --- a/src/main/java/org/apache/sling/feature/Artifact.java +++ b/src/main/java/org/apache/sling/feature/Artifact.java @@ -18,12 +18,12 @@ import java.io.Serializable; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -60,7 +60,7 @@ public class Artifact implements Comparable, Serializable { private final ArtifactId id; /** Artifact metadata. */ - private final Map metadata = new HashMap<>(); + private final Map metadata = new TreeMap<>(); /** * Construct a new artifact diff --git a/src/main/java/org/apache/sling/feature/builder/BuilderUtil.java b/src/main/java/org/apache/sling/feature/builder/BuilderUtil.java index 4d4cdd1..56e35b9 100644 --- a/src/main/java/org/apache/sling/feature/builder/BuilderUtil.java +++ b/src/main/java/org/apache/sling/feature/builder/BuilderUtil.java @@ -149,7 +149,7 @@ static void mergeArtifacts(final Artifacts target, int insertPos = target.size(); int count = 0; for (final Artifact existing : allExistingInTarget) { - if (sourceFeature.getId().toMvnId().equals(existing.getMetadata().get(originKey))) { + if (originKey != null && sourceFeature.getId().toMvnId().equals(existing.getMetadata().get(originKey))) { // If the source artifact came from the same feature, keep them side-by-side // but make sure we add the target ones first - hence, the count selectedArtifacts.add(count++, existing);