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

tdiesler pushed a commit to branch camel-4.10.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.10.x by this push:
     new bc7b2b5c7a2 CAMEL-21753: camel-jbang - Generates duplicate 
application.property entries
bc7b2b5c7a2 is described below

commit bc7b2b5c7a29605fc3613eef519d6d5ed840adf3
Author: Thomas Diesler <tdies...@redhat.com>
AuthorDate: Mon Mar 24 15:09:22 2025 +0100

    CAMEL-21753: camel-jbang - Generates duplicate application.property entries
---
 .../dsl/jbang/core/commands/ExportBaseCommand.java | 45 ++++++++++------------
 .../core/commands/kubernetes/KubernetesExport.java |  1 -
 2 files changed, 21 insertions(+), 25 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index aca19671dd0..ae1bdc1aba4 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -696,37 +696,36 @@ public abstract class ExportBaseCommand extends 
CamelCommand {
             File settings, File profile, File targetDir,
             Function<Properties, Object> customize)
             throws Exception {
-        Properties prop = new CamelCaseOrderedProperties();
-        RuntimeUtil.loadProperties(prop, settings);
+        Properties settingsProps = new CamelCaseOrderedProperties();
+        RuntimeUtil.loadProperties(settingsProps, settings);
 
-        Properties prop2 = new CamelCaseOrderedProperties();
+        Properties profileProps = new CamelCaseOrderedProperties();
         if (profile.exists()) {
-            RuntimeUtil.loadProperties(prop2, profile);
+            RuntimeUtil.loadProperties(profileProps, profile);
         }
-        prop2.putAll(prop);
-        prepareApplicationProperties(prop2);
+        profileProps.putAll(settingsProps);
+        prepareApplicationProperties(profileProps);
 
-        for (Map.Entry<Object, Object> entry : prop.entrySet()) {
+        for (Map.Entry<Object, Object> entry : settingsProps.entrySet()) {
             String key = entry.getKey().toString();
             boolean skip = !key.startsWith("camel.main")
                     || "camel.main.routesCompileDirectory".equals(key)
                     || "camel.main.routesReloadEnabled".equals(key);
             if (skip) {
-                prop2.remove(key);
+                profileProps.remove(key);
             }
         }
 
         if (customize != null) {
-            customize.apply(prop2);
+            customize.apply(profileProps);
         }
 
         // User properties
-        Properties prop3 = new CamelCaseOrderedProperties();
-        prepareUserProperties(prop3);
+        Properties userProps = new CamelCaseOrderedProperties();
+        prepareUserProperties(userProps);
 
-        FileOutputStream fos = new FileOutputStream(new File(targetDir, 
"application.properties"), false);
-        try {
-            for (Map.Entry<Object, Object> entry : prop2.entrySet()) {
+        try (var fos = new FileOutputStream(new File(targetDir, 
"application.properties"), false)) {
+            for (Map.Entry<Object, Object> entry : profileProps.entrySet()) {
                 String k = entry.getKey().toString();
                 String v = entry.getValue().toString();
 
@@ -752,18 +751,16 @@ public abstract class ExportBaseCommand extends 
CamelCommand {
                         fos.write("\n".getBytes(StandardCharsets.UTF_8));
                     }
                 }
-                for (Map.Entry<Object, Object> entryUserProp : 
prop3.entrySet()) {
-                    String uK = entryUserProp.getKey().toString();
-                    String uV = entryUserProp.getValue().toString();
-                    String line = applicationPropertyLine(uK, uV);
-                    if (line != null && !line.isBlank()) {
-                        fos.write(line.getBytes(StandardCharsets.UTF_8));
-                        fos.write("\n".getBytes(StandardCharsets.UTF_8));
-                    }
+            }
+            for (Map.Entry<Object, Object> entryUserProp : 
userProps.entrySet()) {
+                String uK = entryUserProp.getKey().toString();
+                String uV = entryUserProp.getValue().toString();
+                String line = applicationPropertyLine(uK, uV);
+                if (line != null && !line.isBlank()) {
+                    fos.write(line.getBytes(StandardCharsets.UTF_8));
+                    fos.write("\n".getBytes(StandardCharsets.UTF_8));
                 }
             }
-        } finally {
-            IOHelper.close(fos);
         }
     }
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
index 786a9d36bbb..cb3af7c2571 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
@@ -265,7 +265,6 @@ public class KubernetesExport extends Export {
             // Remove OpenAPI spec option to avoid duplicate handling by 
parent export command
             openapi = null;
         }
-        TraitHelper.configureProperties(traitsSpec, applicationProperties);
         TraitHelper.configureContainerImage(traitsSpec, image,
                 resolvedImageRegistry, resolvedImageGroup, projectName, 
getVersion());
         TraitHelper.configureEnvVars(traitsSpec, envVars);

Reply via email to