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

   Fixes [CAMEL-26041](https://issues.apache.org/jira/browse/CAMEL-26041).
   
   Camel does not call the methods of `java.lang.Object` on a bean 
(`BeanInfo.EXCLUDED_METHOD_NAMES`: `equals`, `hashCode`, `wait`, `notify` and 
the others), so `${body.equals('x')}` fails with a `MethodNotFoundException` 
whatever the body is. Since CAMEL-25749 (#28066) the error says what the body 
is and what to write when the body is still the payload, so for a String body 
it said:
   
   > Failed to invoke method: equals('test-value-2') (the body is text (a 
String), set by to at ...: unmarshal it first with the data format of the 
payload (such as unmarshal: json, unmarshal: jacksonXml or unmarshal: csv) to 
read its fields) on the message body of type java.lang.String
   
   The body is not why it failed, and unmarshalling it does not help.
   
   **Changes**
   - `BeanExpression`: when the failed method is one Camel does not call on a 
bean, the error says so, instead of the hint for the body, a List or a Map. For 
`equals` it says to compare with an operator, such as `${body} == 'value'` in 
simple. `getClass` is left out: `BeanInfo` invokes it on its own, so 
`${body.getClass().getName()}` works.
   - `BeanInfo.isExcludedMethodName(String)`: the check of `isValidMethod`, 
public so that the hint uses the same list.
   
   Found while checking the body types of the AWS components at runtime 
(CAMEL-24961), with a log of `${body.equals('test-value-2')}` after an 
aws-secrets-manager getSecret.
   
   **Tests** (`SimpleSyntaxHintsTest`)
   - `testEqualsOnTheBodySaysHowToCompare`: `${body.equals('test-value-2')}` on 
a String body.
   - `testHashCodeOnAListIsNotAMissingElement`: `${body.hashCode()}` on a List 
body.
   - Both fail without the fix. The 984 `Simple*Test` and `Bean*Test` tests of 
camel-core pass.
   
   _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