You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/05/15 15:50:12 UTC

[camel] branch camel-3.x updated (989e1395a00 -> af529956687)

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

davsclaus pushed a change to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 989e1395a00 CAMEL-19352: improve mybatis doc (#10082)
     new f23f132141a CAMEL-19313: resolve option placeholder
     new af529956687 Fixed NPE

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/dsl/jbang/core/commands/CamelCommand.java | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)


[camel] 01/02: CAMEL-19313: resolve option placeholder

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f23f132141a0138567056791d337a55a5e2ff9e4
Author: Croway <fe...@gmail.com>
AuthorDate: Wed May 3 14:02:30 2023 +0200

    CAMEL-19313: resolve option placeholder
---
 .../camel/dsl/jbang/core/commands/CamelCommand.java  | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
index 554f962fb17..583350317bb 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
@@ -26,6 +26,7 @@ import java.util.concurrent.Callable;
 
 import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
 import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
+import org.apache.camel.util.StringHelper;
 import picocli.CommandLine;
 import picocli.CommandLine.IParameterConsumer;
 import picocli.CommandLine.Model.ArgSpec;
@@ -67,9 +68,28 @@ public abstract class CamelCommand implements Callable<Integer> {
             configureLoggingOff();
         }
 
+        replacePlaceholders();
+
         return doCall();
     }
 
+    private void replacePlaceholders() throws Exception {
+        for (CommandLine.Model.ArgSpec argSpec : spec.args()) {
+            String defaultValue = spec.defaultValueProvider().defaultValue(argSpec);
+
+            if (defaultValue != null &&
+                    argSpec instanceof CommandLine.Model.OptionSpec optionSpec) {
+                for (String name : optionSpec.names()) {
+                    String placeholder = "$" + StringHelper.after(name, "--");
+                    if (argSpec.getValue() != null &&
+                            argSpec.getValue().toString().contains(placeholder)) {
+                        argSpec.setValue(argSpec.getValue().toString().replace(placeholder, defaultValue));
+                    }
+                }
+            }
+        }
+    }
+
     public abstract Integer doCall() throws Exception;
 
     public File getStatusFile(String pid) {


[camel] 02/02: Fixed NPE

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit af529956687b1bb705ad35eb74633e04eb92ba13
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon May 15 16:17:25 2023 +0200

    Fixed NPE
---
 .../java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
index 583350317bb..e73f54c4388 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelCommand.java
@@ -75,7 +75,8 @@ public abstract class CamelCommand implements Callable<Integer> {
 
     private void replacePlaceholders() throws Exception {
         for (CommandLine.Model.ArgSpec argSpec : spec.args()) {
-            String defaultValue = spec.defaultValueProvider().defaultValue(argSpec);
+            var provider = spec.defaultValueProvider();
+            String defaultValue = provider != null ? provider.defaultValue(argSpec) : null;
 
             if (defaultValue != null &&
                     argSpec instanceof CommandLine.Model.OptionSpec optionSpec) {