You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Artem St (Jira)" <ji...@apache.org> on 2023/02/18 11:48:00 UTC

[jira] [Updated] (CAMEL-19075) camel-bean. Incorrect choice of overloaded method with several arguments, if one of them has brackets.

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

Artem St updated CAMEL-19075:
-----------------------------
    Affects Version/s: 4.0-M1

> camel-bean. Incorrect choice of overloaded method with several arguments, if one of them has brackets.
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-19075
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19075
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-bean
>    Affects Versions: 3.14.7, 3.20.2, 4.0-M1
>            Reporter: Artem St
>            Priority: Major
>
> camel-bean incorectly choice method if class has overloaded methods and one of the paramets has bracket close symbol ")".
>  
> Here is a test case:
>  
> {code:java}
> @ExtendWith(MockitoExtension.class)
> public class BeanProcessorOverloadedMethodsWithBracketsTest extends CamelTestSupport {
>     private final String strArgWithBrackets = ")(string_with_brackets()))())";
>     @Test
>     public void testOverloadedMethodWithBracketsParams() throws InterruptedException {
>         template.sendBody("direct:start", null);
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         String receivedExchangeBody = mock.getExchanges().get(0).getMessage().getBody(String.class);
>         assertEquals(new MyOverloadedClass().myMethod(strArgWithBrackets, strArgWithBrackets), receivedExchangeBody);
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() {
>         return new RouteBuilder() {
>             public void configure() {
>                 from("direct:start")
>                         .bean(MyOverloadedClass.class, "myMethod('" + strArgWithBrackets + "', '" + strArgWithBrackets + "')")
>                         .to("mock:result");
>             }
>         };
>     }
>     public static class MyOverloadedClass {
>         public String myMethod() {
>             return "";
>         }
>         public String myMethod(String str) {
>             return str;
>         }
>         public String myMethod(String str1, String str2) {
>             return str1 + str2;
>         }
>     }
> } {code}
> In test example above I am trying to call myMethod with two arguments, but instead of it camel-bean chooses method with one argument.
> Test returns the assertion error:
> {code:java}
> org.opentest4j.AssertionFailedError: 
> Expected :)(string_with_brackets()))()))(string_with_brackets()))())
> Actual   :)(string_with_brackets()))()){code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)