You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/11/21 15:33:51 UTC

[GitHub] [camel] mrinalsharma opened a new pull request, #8749: Fixed CAMEL-18719

mrinalsharma opened a new pull request, #8749:
URL: https://github.com/apache/camel/pull/8749

   This pull request fixes [CAMEL-18719](https://issues.apache.org/jira/browse/CAMEL-18719)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] essobedo commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028408441


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");

Review Comment:
   If you check these lines https://github.com/apache/camel/blob/59c6450582fa662c168021360c42f1e78a4cc438/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java#L266-L269, you will see that `profileProperties` is `null` if the file doesn't exist which can occur so I confirm that `properties` can be `null`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] mrinalsharma commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028403018


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");

Review Comment:
   My understanding is that properties are expected to be not null, if that's not the case we can see NullPointerException at so many other places.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8749:
URL: https://github.com/apache/camel/pull/8749#issuecomment-1323198091

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus merged pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
davsclaus merged PR #8749:
URL: https://github.com/apache/camel/pull/8749


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] mrinalsharma commented on pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on PR #8749:
URL: https://github.com/apache/camel/pull/8749#issuecomment-1322449756

   In the method getDependencies(), we are trying to read `property camel.jbang.dependencies`. If its null then the method should return empty string.
   
   Run.java:
   if getDependencies() doesn't return blank then merge the dependencies read from file and the dependencies passes as --deps parameter.
   
   ExportQuarkus.java
   `camel-quarkus-core,camel-quarkus-platform-http,camel-quarkus-microprofile-health` are  already defined in `quarkus-pom.tmpl'` so there is no need to define them again. Adding again in pom.xml cause a compilation error.
   
   ExportBaseCommand.jaja
   The change avoids adding a blank dependency in pom.xml. Blank dependency causes a compilation error.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] essobedo commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028235876


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");
+        if (deps != null) {
+            deps = deps.trim();
+            if (deps.length() > 0 && deps.charAt(0) == ',') {
+                deps = deps.substring(1);
+            }
+            if (deps.length() > 0 && deps.charAt(deps.length() - 1) == ',') {
+                deps = deps.substring(0, deps.lastIndexOf(","));
+            }
+        } else {
+            deps = new String("");

Review Comment:
   ```suggestion
               deps = "";
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] mrinalsharma commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028383824


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java:
##########
@@ -342,15 +342,15 @@ private int run() throws Exception {
         writeSetting(main, profileProperties, "camel.jbang.console", console ? "true" : "false");
         writeSetting(main, profileProperties, "camel.main.routesCompileDirectory", WORK_DIR);
         // merge existing dependencies with --deps
-        String dep = profileProperties != null ? profileProperties.getProperty("camel.jbang.dependencies") : null;
-        if (dep == null) {
-            dep = dependencies;
-        } else if (dependencies != null && !dependencies.equals(dep)) {
-            dep += "," + dependencies;
-        }
-        if (dep != null) {
-            main.addInitialProperty("camel.jbang.dependencies", dep);
-            writeSettings("camel.jbang.dependencies", dep);
+        String deps = RuntimeUtil.getDependencies(profileProperties);
+        if (deps.isBlank()) {
+            deps = dependencies;
+        } else if (dependencies != null && !dependencies.equals(deps)) {
+            deps += "," + dependencies;
+        }
+        if (!deps.isBlank()) {

Review Comment:
   Thanks for the clarification.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] essobedo commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028375427


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");

Review Comment:
   To be clear, if `properties` is `null`, calling `properties.getProperty("camel.jbang.dependencies")` will throw a `NullPointerException`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] essobedo commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028232527


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");

Review Comment:
   Warning `properties` could be null according to https://github.com/apache/camel/pull/8749/files#diff-b62a4b0acb50014174399c284b5540cf84016571e5c789a23edc8d843692721cL345



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] essobedo commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028372379


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java:
##########
@@ -342,15 +342,15 @@ private int run() throws Exception {
         writeSetting(main, profileProperties, "camel.jbang.console", console ? "true" : "false");
         writeSetting(main, profileProperties, "camel.main.routesCompileDirectory", WORK_DIR);
         // merge existing dependencies with --deps
-        String dep = profileProperties != null ? profileProperties.getProperty("camel.jbang.dependencies") : null;
-        if (dep == null) {
-            dep = dependencies;
-        } else if (dependencies != null && !dependencies.equals(dep)) {
-            dep += "," + dependencies;
-        }
-        if (dep != null) {
-            main.addInitialProperty("camel.jbang.dependencies", dep);
-            writeSettings("camel.jbang.dependencies", dep);
+        String deps = RuntimeUtil.getDependencies(profileProperties);
+        if (deps.isBlank()) {
+            deps = dependencies;
+        } else if (dependencies != null && !dependencies.equals(deps)) {
+            deps += "," + dependencies;
+        }
+        if (!deps.isBlank()) {

Review Comment:
   Warning `deps` could be `null` in case `deps.isBlank()` returns initially `true` and `dependencies` is `null`. In this case, we would end up with an NPE



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] mrinalsharma commented on a diff in pull request #8749: Fixed Camel 18719 : camel-jbang - Adding the dependency of camel-quarkus-core creates two entries in exported POM.xml

Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on code in PR #8749:
URL: https://github.com/apache/camel/pull/8749#discussion_r1028596872


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java:
##########
@@ -83,4 +83,20 @@ public static void loadProperties(Properties properties, File file) throws IOExc
         }
     }
 
+    public static String getDependencies(Properties properties) {
+        String deps = properties.getProperty("camel.jbang.dependencies");

Review Comment:
   Sure, I should have the fix soon.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org