Deepak created CAMEL-22978:
------------------------------
Summary: Camel Bean Constructor Fails to Resolve String Parameters
with Quotes in Overloaded Factory Method
Key: CAMEL-22978
URL: https://issues.apache.org/jira/browse/CAMEL-22978
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 4.14.2
Reporter: Deepak
When creating a Camel {{<bean>}} using a factory method that is
{*}overloaded{*}, passing a {{String}} parameter enclosed in single or double
quotes causes bean instantiation to fail. Camel strips quotes before type
determination, resulting in the {*}String parameter type being resolved as
{{null}}{*}, which prevents matching the correct overloaded method.
*Steps to Reproduce:*
*Define a Camel bean with a factory method that is* {*}overloaded{*}{*},
e.g.,{*}
*<camel:bean
factoryBean="com.esb.camel.http.ahc.configurer.impl.ClientConfigFactory-bean"*
*factoryMethod="getBinding"*
*name="BIC_Http_receiver_with_Certificate_Auth|binding_Receiver_HTTP"*
*type="org.apache.camel.component.ahc.AhcBinding">*
*<camel:constructors>*
*<camel:constructor index="0" value="false"/>*
*<camel:constructor index="1" value="'picouser'"/>*
*</camel:constructors>*
*</camel:bean>*
*Observe that the factory method {{getBinding(boolean, String)}} fails to
match, even though the arguments are correct.*
**
*Root Cause:*
* In {{{}org.apache.camel.support.PropertyBindingSupport{}}}, the method
{{newInstanceFactoryParameters()}} *strips single/double quotes* from
{{String}} constructor arguments before type resolution.
* {{findMatchingFactoryMethod()}} relies on {{getValidParameterType()}} to
detect the parameter type.
* Because quotes are already removed, {{getValidParameterType()}} returns
{{null}} for {{String}} parameters.
* If the factory method is {*}overloaded{*}, Camel cannot disambiguate between
methods, causing bean creation to fail.
*Impact:*
* Bean creation fails when:
** The factory method is overloaded, and
** The argument is of type {{String}} passed with quotes (single or double).
*Example Overloaded Methods That Fail:*
*// Factory class*
*public AhcBinding getBinding(boolean flag, String user) \{ ... }*
*public AhcBinding getBinding(boolean flag, boolean option) \{ ... }*
*Expected Behavior:*
Camel should identify the parameter type and then strip the quotes.
**
--
This message was sent by Atlassian Jira
(v8.20.10#820010)