Repository navigation
CAMEL-26041: camel-bean - a call of equals on the body says how to compare, not to unmarshal the body - #28315
Conversation
…mpare, not to unmarshal the body
Camel does not call equals, hashCode and the other methods of
java.lang.Object on a bean, so ${body.equals('x')} fails for any body.
Since CAMEL-25749 the error added the body hint for a body that is still
the payload, and so told to unmarshal a String body to read its fields.
The error now says that Camel does not call the method, and for equals
to compare with an operator, such as ${body} == 'value' in simple.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet-bot
left a comment
There was a problem hiding this comment.
Clean, well-scoped fix. The new isExcludedMethodName check correctly intercepts excluded-method failures before the misleading body/unmarshal hint is generated — the diagnostic message now accurately reflects what happened.
The public API addition (AnnotationBeanMethodInvocationStrategy.isExcludedMethodName) is justified: it exposes the exclusion check that was previously internal, enabling subclasses to customize exclusion lists. The test covers the key case (equals with non-matching body type).
No issues found.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
🧪 CI tested the following changed modules:
🔁 3 tests passed only after a retry on JDK 21 (3 retried attempts) Recovered flaky tests on JDK 21 (3)
🔬 Scalpel shadow comparison — Scalpel: 490 of 707 tested, 27 compile-only — current: 492 all testedMaveniverse Scalpel detected 490 affected modules (current approach: 492). Skip-tests mode would test 490 modules (2 direct + 488 downstream), skip tests for 27 (generated code, meta-modules) Modules only in current approach (2)
Modules Scalpel would test (490)
Modules with tests skipped (27)
Build reactor — dependencies compiled but only changed modules were tested (2 modules, 10.0s total)Total reactor time: 10.0s
Top 20 slowest modules:
|
Fixes CAMEL-26041.
Camel does not call the methods of
java.lang.Objecton a bean (BeanInfo.EXCLUDED_METHOD_NAMES:equals,hashCode,wait,notifyand the others), so${body.equals('x')}fails with aMethodNotFoundExceptionwhatever 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: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. Forequalsit says to compare with an operator, such as${body} == 'value'in simple.getClassis left out:BeanInfoinvokes it on its own, so${body.getClass().getName()}works.BeanInfo.isExcludedMethodName(String): the check ofisValidMethod, 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.Simple*TestandBean*Testtests of camel-core pass.Claude Code on behalf of davsclaus
🤖 Generated with Claude Code