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

   https://issues.apache.org/jira/browse/CAMEL-26566
   
   A Groovy expression such as `"not enough ${sku}"` returns a GString 
(`org.codehaus.groovy.runtime.GStringImpl`), not a String. `GroovyExpression` 
converts the result to the type that is asked for, and setBody, setHeader, 
setVariable and transform ask for `Object`, so the GString stayed as it is. A 
GString is not equal to a String, and components that check for a String do not 
take it as text: camel-jms sent it as an ObjectMessage, which is off by default 
since 4.14.
   
   Found by the local-model benchmark (example 
connect-service-jms-request-reply, step 3): all 6 runs that wrote a Groovy 
script hit it.
   
   **Change**
   - `GroovyLanguage.scriptResult` turns a GString result into a String. 
`GroovyExpression` uses it, and so does `ScriptingLanguage.evaluate` (beans 
that a script creates).
   - The Python and JavaScript languages already return a String for their text.
   - groovy-language.adoc has a short section on text with placeholders, and 
the 4.24 upgrade guide has an entry.
   
   **What users can notice**
   - A body, header or variable that a Groovy expression sets is now a String 
where it was a GString.
   - A Groovy predicate that returns the GString `"false"` or `""` no longer 
matches. Before, every GString matched.
   - Not covered: a GString inside a Map or List that a script returns.
   
   **Tests**
   - New `GroovyGStringResultTest` (5 tests); they fail without the change.
   - camel-groovy: 129 tests pass (1 skipped, `@Disabled` before this change).
   
   Related: CAMEL-26567 (camel-jms and camel-sjms send any CharSequence as a 
TextMessage). Both PRs add an entry at the same place in the upgrade guide, so 
the second one to merge needs a rebase.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to