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

   Follow-up to #26477 (CAMEL-24708). **Stacked on #26477**: the base is its 
branch because this PR also updates the `groovy` script card of 
`camel_catalog_doc kind=api` that #26477 introduces; GitHub retargets it to 
`main` once #26477 is merged. The `camel-groovy` part on its own is 
backportable.
   
   ### Why
   
   Every other script language binds the current message as `message` 
(javascript, python, python3 with host access, the joor `java` language has a 
`message` parameter), and `Exchange.getMessage()` is the Camel 4 name every 
model and most users reach for. Groovy only had the template-era `request` / 
`in`. Worse, the `MissingPropertyException` hint added by CAMEL-24698 told the 
user that the script variables are "exchange, **message**, body, headers, ..." 
although `message` did not exist, so a script that followed the hint failed a 
second time.
   
   ### What
   
   - `GroovyExpression.ExchangeBinding`: `message` is exposed, the same object 
as `request` / `in` (`exchange.getIn()`, which is `getMessage()` in Camel 4).
   - The hint text is a constant (`SCRIPT_VARIABLES_HINT`: exchange, message, 
body, headers, variables, exchangeProperties, exception, camelContext, 
attachments and log) with a test that every name it lists is in 
`EXCHANGE_VARIABLES`, so it cannot drift again.
   - `groovy-language.adoc` table gets the `message` row (catalog mirror 
regenerated); 4.23 upgrade guide notes the new variable and that a 
`GroovyShellFactory` global named `message` is now hidden like the other 
exchange variable names.
   - `CatalogDocs` groovy card: `message` with `request` / `in` as aliases; the 
"there is no message variable" note is gone.
   
   ### Tests
   
   `GroovyExpressionBindingTest` (message is the exchange message, in 
`binding.variables`, hint names exist), `GroovyMissingPropertyHintTest` (a 
script using `message` as the hint says works), `CatalogDocsTest` (card and 
drift test). Whole camel-groovy suite: 103 tests green.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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