You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Federico Mariani (Jira)" <ji...@apache.org> on 2026/07/15 14:08:00 UTC

[jira] [Updated] (CAMEL-24102) camel-bean: AmbiguousMethodCallException from body-conversion matching lists the same method twice instead of the actual candidates

     [ https://issues.apache.org/jira/browse/CAMEL-24102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Federico Mariani updated CAMEL-24102:
-------------------------------------
    Attachment: BeanAmbiguousExceptionDuplicateMethodTest.java

> 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
>            Priority: Minor
>         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)