You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "ammachado (via GitHub)" <gi...@apache.org> on 2023/03/10 20:10:33 UTC

[GitHub] [camel] ammachado opened a new pull request, #9510: Convert expression when setting header / property on message / exchange.

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

   # Description
   
   Convert an expression to an object value when it is used on a `setHeader` method on a `Message` or on a `setProperty` on an `Exchange`
   
   <!--
   - Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   -->
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has 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.
   -->
   
   - [ ] I formatted the code using `mvn -Pformat,fastinstall install && mvn -Psourcecheck`
     Local build is failing with JAXB generation errors on `camel-spring-xml`
   
   <!-- 
   You can run the aforementioned command in your module so that the build auto-formats your code and the source check verifies that is complies with our coding style. This will also be verified as part of the checks and your PR may be rejected if the checkstyle does not pass.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/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.

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 closed pull request #9510: Convert expression when setting header / property on message / exchange.

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus closed pull request #9510: Convert expression when setting header / property on message / exchange.
URL: https://github.com/apache/camel/pull/9510


-- 
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] ammachado commented on pull request #9510: Convert expression when setting header / property on message / exchange.

Posted by "ammachado (via GitHub)" <gi...@apache.org>.
ammachado commented on PR #9510:
URL: https://github.com/apache/camel/pull/9510#issuecomment-1464994118

   I helped debugging a production issue where some code was refactored from a route definition (`from(...).setHeader("name", constant("value")`) to a processor (`exchange.getMessage().setHeader("name", constant("value")`).  Where previously the header was set to the correct value, after the refactor the header was being set to `constant{value}`.
   
   The `setHeader` and `setProperty` methods on Java DSL have overloads for `Expression` and `Supplier` to resolve the values, where the methods on the message / exchange don't.


-- 
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 #9510: Convert expression when setting header / property on message / exchange.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9510:
URL: https://github.com/apache/camel/pull/9510#issuecomment-1464478735

   :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] github-actions[bot] commented on pull request #9510: Convert expression when setting header / property on message / exchange.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9510:
URL: https://github.com/apache/camel/pull/9510#issuecomment-1464360235

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :warning: Please note that the changes on this PR may be **tested automatically**. 
   
   If necessary Apache Camel Committers may access logs and test results in the job summaries!


-- 
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 commented on pull request #9510: Convert expression when setting header / property on message / exchange.

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #9510:
URL: https://github.com/apache/camel/pull/9510#issuecomment-1465121743

   okay but this PR is wrong as the Route DSL uses the mode/expression, and Java API uses the object as-is. So to set a constant value, set it directly.
   
   The setHeader/setProperty are optimized for core use and we should not add overhead with this. Also when you set the value you evaluate it as well this is wrong, as some Camel components allow using an Expression as a header for dynamic computation that they evaluate later.
   
   So the correct solution is to
   
   exchange.getMessage().setHeader("name", "value")
   
   


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