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

davsclaus 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 791bf081821 Close resolver
791bf081821 is described below

commit 791bf0818215255658185f2c86980c571444713e
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Jan 8 21:09:38 2023 +0100

    Close resolver
---
 .../dsl/jbang/core/commands/ExportBaseCommand.java | 49 ++++++++++++----------
 1 file changed, 26 insertions(+), 23 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 c31689c3abe..cc7d1be3e52 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
@@ -385,33 +385,36 @@ abstract class ExportBaseCommand extends CamelCommand {
         }
 
         FileOutputStream fos = new FileOutputStream(new File(targetDir, 
"application.properties"), false);
-        for (Map.Entry<Object, Object> entry : prop2.entrySet()) {
-            String k = entry.getKey().toString();
-            String v = entry.getValue().toString();
+        try {
+            for (Map.Entry<Object, Object> entry : prop2.entrySet()) {
+                String k = entry.getKey().toString();
+                String v = entry.getValue().toString();
 
-            boolean skip = k.startsWith("camel.jbang.") || 
k.startsWith("jkube.");
-            if (skip) {
-                continue;
-            }
+                boolean skip = k.startsWith("camel.jbang.") || 
k.startsWith("jkube.");
+                if (skip) {
+                    continue;
+                }
 
-            // files are now loaded in classpath
-            v = v.replaceAll("file:", "classpath:");
-            if ("camel.main.routesIncludePattern".equals(k)) {
-                // camel.main.routesIncludePattern should remove all .java as 
we use spring boot
-                // to load them
-                // camel.main.routesIncludePattern should remove all file: 
classpath: as we copy
-                // them to src/main/resources/camel where camel auto-load from
-                v = Arrays.stream(v.split(","))
-                        .filter(n -> !n.endsWith(".java") && 
!n.startsWith("file:") && !n.startsWith("classpath:"))
-                        .collect(Collectors.joining(","));
-            }
-            if (!v.isBlank()) {
-                String line = applicationPropertyLine(k, v);
-                fos.write(line.getBytes(StandardCharsets.UTF_8));
-                fos.write("\n".getBytes(StandardCharsets.UTF_8));
+                // files are now loaded in classpath
+                v = v.replaceAll("file:", "classpath:");
+                if ("camel.main.routesIncludePattern".equals(k)) {
+                    // camel.main.routesIncludePattern should remove all .java 
as we use spring boot
+                    // to load them
+                    // camel.main.routesIncludePattern should remove all file: 
classpath: as we copy
+                    // them to src/main/resources/camel where camel auto-load 
from
+                    v = Arrays.stream(v.split(","))
+                            .filter(n -> !n.endsWith(".java") && 
!n.startsWith("file:") && !n.startsWith("classpath:"))
+                            .collect(Collectors.joining(","));
+                }
+                if (!v.isBlank()) {
+                    String line = applicationPropertyLine(k, v);
+                    fos.write(line.getBytes(StandardCharsets.UTF_8));
+                    fos.write("\n".getBytes(StandardCharsets.UTF_8));
+                }
             }
+        } finally {
+            IOHelper.close(fos);
         }
-        IOHelper.close(fos);
     }
 
     protected void copyMavenWrapper() throws Exception {

Reply via email to