[
https://issues.apache.org/jira/browse/CAMEL-24102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-24102.
---------------------------------
Resolution: Fixed
> camel-bean: AmbiguousMethodCallException from body-conversion matching lists
> the same method twice instead of the actual candidates
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24102
> URL: https://issues.apache.org/jira/browse/CAMEL-24102
> Project: Camel
> Issue Type: Bug
> Components: camel-bean
> Affects Versions: 4.21.0
> Reporter: Federico Mariani
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.22.0
>
> Attachments: BeanAmbiguousExceptionDuplicateMethodTest.java
>
>
> When bean method selection falls into the body-conversion matching loop and
> more than one method's body parameter is convertible from the message body,
> {{BeanInfo.chooseBestPossibleMethodInfo}} throws:
> {code:java}
> if (matchCounter > 1) {
> throw new AmbiguousMethodCallException(exchange, Arrays.asList(matched,
> matched));
> }
> {code}
> {{matched}} only holds the *last* convertible method, so the exception
> reports one method *listed twice* and omits the other candidate(s) entirely.
> Users debugging the ambiguity get actively misleading information. Present
> since 2010 (commit a455c4bb8041).
> *Suggested fix*
> Collect the convertible candidates in a list during the loop and pass that
> list to the exception.
> *Reproducer*
> Attached test {{BeanAmbiguousExceptionDuplicateMethodTest}} fails on main
> (4.22.0-SNAPSHOT). With a bean having {{foo(Integer)}} and {{bar(Double)}}
> and a String body {{"123"}} (convertible to both), the exception reports:
> {noformat}
> [public java.lang.String ...MyAmbiguousBean.foo(java.lang.Integer),
> public java.lang.String ...MyAmbiguousBean.foo(java.lang.Integer)]
> {noformat}
> i.e. {{foo}} twice, {{bar}} not mentioned at all.
> _This issue was found by an AI-assisted code review. Reported by Claude Code
> on behalf of [~fmariani] (GitHub: Croway)._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)