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 2021/02/20 17:42:53 UTC

[GitHub] [camel] jameshilliard opened a new pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

jameshilliard opened a new pull request #5107:
URL: https://github.com/apache/camel/pull/5107


   Fixes `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.

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



[GitHub] [camel] davsclaus commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-783459950


   The method is used from other parts in camel that are not in the same package, so it has to be public.


----------------------------------------------------------------
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.

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



[GitHub] [camel] davsclaus commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-782817886


   Okay but as an end user you should not call `.asRouteDefinition()` its for internal use


----------------------------------------------------------------
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.

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



[GitHub] [camel] jameshilliard commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
jameshilliard commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-782743758


   > I wonder what example / use-case you had that could cause this NPE?
   
   I was messing around with route templates and hit this error, here's the reproducer:
   ```java
   diff --git a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletRouteTest.java b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletRouteTest.java
   index 15c0cc853fa..43a02038760 100644
   --- a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletRouteTest.java
   +++ b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletRouteTest.java
   @@ -56,6 +56,7 @@ public class KameletRouteTest extends CamelTestSupport {
                public void configure() throws Exception {
                    routeTemplate("echo")
                            .templateParameter("prefix")
   +                        .asRouteDefinition()
                            .from("kamelet:source")
                            .setBody().simple("{{prefix}}-${body}");
   ```


----------------------------------------------------------------
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.

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



[GitHub] [camel] jameshilliard commented on a change in pull request #5107: Kamelet: Ensure camel route input is not null.

Posted by GitBox <gi...@apache.org>.
jameshilliard commented on a change in pull request #5107:
URL: https://github.com/apache/camel/pull/5107#discussion_r581235654



##########
File path: components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/Kamelet.java
##########
@@ -116,6 +116,10 @@ public static RouteDefinition templateToRoute(RouteTemplateDefinition in, Map<St
         RouteDefinition def = in.asRouteDefinition();
         def.setId(rid);
 
+        if (def.getInput() == null) {
+            throw new IllegalArgumentException("Camel route " + rid + " input does not exist.");

Review comment:
       How's this wording for the error message?




----------------------------------------------------------------
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.

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



[GitHub] [camel] davsclaus commented on a change in pull request #5107: Kamelet: Ensure camel route input is not null.

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5107:
URL: https://github.com/apache/camel/pull/5107#discussion_r581271312



##########
File path: components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/Kamelet.java
##########
@@ -116,6 +116,10 @@ public static RouteDefinition templateToRoute(RouteTemplateDefinition in, Map<St
         RouteDefinition def = in.asRouteDefinition();
         def.setId(rid);
 
+        if (def.getInput() == null) {
+            throw new IllegalArgumentException("Camel route " + rid + " input does not exist.");

Review comment:
       Yes this is fine




----------------------------------------------------------------
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.

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



[GitHub] [camel] davsclaus commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-782742524


   I wonder what example / use-case you had that could cause this NPE? I am asking because a camel  route should always have 1 input.


----------------------------------------------------------------
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.

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



[GitHub] [camel] jameshilliard commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
jameshilliard commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-782818414


   > Okay but as an end user you should not call `.asRouteDefinition()` its for internal use
   
   hmm, shouldn't it not be public if that is the case?


----------------------------------------------------------------
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.

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



[GitHub] [camel] davsclaus merged pull request #5107: Kamelet: Ensure camel route input is not null.

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


   


----------------------------------------------------------------
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.

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



[GitHub] [camel] davsclaus commented on pull request #5107: Kamelet: Don't call getEndpointUri() on null input.

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5107:
URL: https://github.com/apache/camel/pull/5107#issuecomment-782817966


   Instead of avoiding the NPE then you can update the PR to check that input is not null and report an error if so.


----------------------------------------------------------------
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.

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