From c30798d7a18a49785431b347e28f9ad4071c56d8 Mon Sep 17 00:00:00 2001 From: Bartosz Spyrko-Smietanko Date: Thu, 26 Oct 2023 11:55:06 +0100 Subject: [PATCH] [GAL-353] Sort hashes entries in .galleon/hashes folder --- .../java/org/jboss/galleon/ProvisioningManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jboss/galleon/ProvisioningManager.java b/core/src/main/java/org/jboss/galleon/ProvisioningManager.java index 3012698d..b4f0b4b9 100644 --- a/core/src/main/java/org/jboss/galleon/ProvisioningManager.java +++ b/core/src/main/java/org/jboss/galleon/ProvisioningManager.java @@ -25,8 +25,10 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.TreeSet; import org.jboss.galleon.config.FeaturePackConfig; import org.jboss.galleon.config.ProvisioningConfig; @@ -870,7 +872,14 @@ private void persistChildHashes(Path hashes, FsEntry entry, List dirs, int dirsTotal = 0; BufferedWriter writer = null; try { - for (FsEntry child : entry.getChildren()) { + final TreeSet sortedChildren = new TreeSet<>(new Comparator() { + @Override + public int compare(FsEntry e1, FsEntry e2) { + return e1.getName().compareTo(e2.getName()); + } + }); + sortedChildren.addAll(entry.getChildren()); + for (FsEntry child : sortedChildren) { if (!child.isDir()) { if (writer == null) { writer = Files.newBufferedWriter(target.resolve(Constants.HASHES));