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/03/05 09:46:56 UTC

[GitHub] [camel] squakez opened a new pull request #5177: fix(mongodb): converter failure

squakez opened a new pull request #5177:
URL: https://github.com/apache/camel/pull/5177


   Checking that the value to be converted from a String to List is an array in order to avoid a BsonInvalidOperationException when the method is called.
   
   With this PR we fix a minor issue caused when we try to convert to a List, ie:
   ```
   if (exchange.getIn().getBody(List.class) != null) {
                       List<?> body = exchange.getIn().getBody(List.class);
   ...
   ```
   The above call would fail with a single document as the method assumes it's going to be an array of them. We should therefore return `null` if the passed in value is not an array and not proceed to the conversion.
   
   <!-- Uncomment and fill this section if your PR is not trivial
   - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/master/CONTRIBUTING.md
   -->
   


----------------------------------------------------------------
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 #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       We need to make @Converter(allowNull = true) as the converter can return null as a valid response




----------------------------------------------------------------
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] squakez commented on a change in pull request #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       I did not explain myself properly, sorry. I was meaning that according the documentation, when the converted value is expected to be a _miss_ then `null` should be returned. If `null` is allowed to be a valid response, then, we should include the annotation as you said. In this case, `null` won't be a valid response, but just a _miss_, so I understand that the annotation is not needed. At least, this is what I understood from the doc, or am I misunderstanding something?




----------------------------------------------------------------
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 #5177: fix(mongodb): converter failure

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


   


----------------------------------------------------------------
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 #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       Yes can you add that fix




----------------------------------------------------------------
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 #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       Yes you misunderstod. A miss is regarded as a from -> to combo that should not be attempted anymore in the future (miss). 




----------------------------------------------------------------
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] squakez commented on a change in pull request #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       In this case this should be considered be a _miss_. According the [documentation](https://camel.apache.org/manual/latest/type-converter.html#TypeConverter-Returningnullvalues), this would be the way to handle.




----------------------------------------------------------------
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] squakez commented on a change in pull request #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       In this case it should be considered be a _miss_. According the [documentation](https://camel.apache.org/manual/latest/type-converter.html#TypeConverter-Returningnullvalues), this would be the way to handle.




----------------------------------------------------------------
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] squakez commented on a change in pull request #5177: fix(mongodb): converter failure

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



##########
File path: components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
##########
@@ -119,6 +119,9 @@ private static boolean isBson(byte[] input) {
 
     @Converter

Review comment:
       Thanks for clarifying. I've just pushed the change.




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