[
https://issues.apache.org/jira/browse/CAMEL-25330?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-25330.
---------------------------------
Fix Version/s: 4.23.0
Resolution: Fixed
Fixed on main via https://github.com/apache/camel/pull/27359
> camel-groovy - a property read on a body that is still text says to unmarshal
> it first
> --------------------------------------------------------------------------------------
>
> Key: CAMEL-25330
> URL: https://issues.apache.org/jira/browse/CAMEL-25330
> Project: Camel
> Issue Type: Improvement
> Components: camel-groovy
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.23.0
>
>
> A Groovy expression that reads fields of the body, such as {{body.find {
> it.sku == headers.sku }}}, fails when the body is still the text of the
> payload (a byte[] or a String holding JSON), because Groovy then iterates the
> bytes or characters:
> {noformat}groovy.lang.MissingPropertyException: No such property: sku for
> class: java.lang.Byte (the script variables are exchange, message, body,
> headers, ...){noformat}
> The hint lists the script variables, which are fine; the cause is that the
> body was not unmarshalled. Found in the local-model benchmark (round 4,
> contracts/openapi-server step 1): the model left out the unmarshal (or wrote
> marshal) before a Groovy lookup, in 2 of 5 runs, and got this message.
> Proposal: when the missing property was looked up on a Byte, Character or
> String and the message body is a byte[] or a String, the hint says: the body
> is still text (a byte[]), not parsed data: unmarshal it first (unmarshal:
> json for JSON) to read its fields.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)