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

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 896ff8a4bd54 CAMEL-26480: camel-jbang - sort directory file streams 
for deterministic file ordering
896ff8a4bd54 is described below

commit 896ff8a4bd541b5f5dee875d48503f8b2c478a62
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Nov 2 09:41:19 2026 +0100

    CAMEL-26480: camel-jbang - sort directory file streams for deterministic 
file ordering
    
    It is better to be deterministic even if it costs slightly more in 
performance. On the performance side, the list size is expected to be small 
since Camel JBang is intended for prototyping, so this overhead is negligible.
    
    Co-authored-by: IBM Bob 2.2.1 <[email protected]>
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java   | 6 +++---
 .../java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java    | 3 ++-
 .../main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java   | 1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
index f1dacae8e02c..5a6b16e166f5 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
@@ -318,7 +318,7 @@ public class RunPipeline {
             // silent-run then auto-detect all initial files for source-dir
             Path sourceDirPath = Paths.get(sourceDir);
             try (Stream<Path> paths = Files.list(sourceDirPath)) {
-                paths.forEach(p -> 
files.add(sourceDirPath.resolve(p.getFileName()).toString()));
+                paths.sorted().forEach(p -> 
files.add(sourceDirPath.resolve(p.getFileName()).toString()));
             } catch (IOException e) {
                 // Ignore
             }
@@ -330,8 +330,8 @@ public class RunPipeline {
                     return false;
                 } else {
                     // silent-run then auto-detect all files
-                    try {
-                        Files.list(Paths.get("."))
+                    try (Stream<Path> paths = Files.list(Paths.get("."))) {
+                        paths.sorted()
                                 .map(p -> p.getFileName().toString())
                                 .forEach(files::add);
                     } catch (IOException e) {
diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java
 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java
index 313a26dea9f5..57e41ac05953 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java
@@ -75,7 +75,7 @@ public final class ExportHelper {
 
     public static List<Path> walkResourceDir(Path dirPath) throws IOException {
         try (Stream<Path> walk = Files.walk(dirPath)) {
-            List<Path> files = walk.filter(Files::isRegularFile).toList();
+            List<Path> files = 
walk.filter(Files::isRegularFile).sorted().toList();
             if (files.size() > MAX_RESOURCE_DIR_FILES) {
                 throw new IllegalArgumentException(
                         "--resource-dirs directory contains " + files.size()
@@ -101,6 +101,7 @@ public final class ExportHelper {
                     return false;
                 }
             })
+                    .sorted()
                     .forEach(f -> files.add(base + f.getFileName()));
         } catch (IOException e) {
             // Ignore
diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
index 6960df98d326..42b2f73b0928 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
@@ -1286,6 +1286,7 @@ abstract class Exporter {
     protected void copyApplicationPropertiesFiles(Path srcResourcesDir) throws 
Exception {
         try (Stream<Path> files = Files.list(request.baseDir)) {
             files.filter(p -> Files.isRegularFile(p))
+                    .sorted()
                     .filter(p -> {
                         String fileName = p.getFileName().toString();
                         String ext = FileUtil.onlyExt(fileName);

Reply via email to