Marco Carletti created CAMEL-23914:
--------------------------------------
Summary: camel-jbang export fails with TypeConversionException
when kamelet has optional Long property
Key: CAMEL-23914
URL: https://issues.apache.org/jira/browse/CAMEL-23914
Project: Camel
Issue Type: Bug
Components: camel-jbang
Affects Versions: 4.21.0
Reporter: Marco Carletti
When exporting an integration that uses a kamelet with an optional property of
type Long (e.g. salesforce-source kamelet with replayId), the camel-launcher
export fails with a {_}TypeConversionException{_}.
During export, unresolved optional properties ({_}{{?replayId}}{_}) are
replaced with _@@CamelMagicValue@@_ by {_}ExportPropertiesParser{_}. The
_ExportTypeConverter_ registered in _KameletMain.setupExport()_ should handle
this placeholder, but in the
camel-launcher fat JAR the core _CamelBaseBulkConverterLoader_ overwrites it
via _CoreTypeConverterRegistry.addConverter()_ — which does a raw
_converters.put()_ bypassing the _TypeConverterExists.Override_ policy. The
core converter then
attempts _Long.valueOf("@@CamelMagicValue@@")_ and throws
{_}NumberFormatException{_}.
This does not happen with standalone camel-jbang because components are
downloaded lazily and fewer _BulkTypeConverterLoader_ implementations are
scanned at startup.
The fix is to handle _@@CamelMagicValue@@_ directly in
_PropertyConfigurerSupport.property()_ for all primitive/wrapper types before
calling {_}mandatoryConvertTo(){_}, returning type-safe defaults without
relying on the type converter registry.
Reproducer:
{code:yaml}
# salesforce-minimal.yaml
- route:
from:
uri: 'kamelet:salesforce-source'
parameters:
password: 'password'
clientId: 'client'
loginUrl: 'https://login.salesforce.com'
query: 'query'
notifyForOperationCreate: true
topicName: 'topic'
clientSecret: 'secret'
userName: 'user'
steps:
- log: '${body}' {code}
{code:bash}
java -jar camel-launcher.jar export salesforce-minimal.yaml \
--runtime quarkus --gav com.test:example:1.0 --dir .
{code}
Stack trace:
{code:java}
Caused by: org.apache.camel.TypeConversionException: Error during type
conversion
from type: java.lang.String to the required type: java.lang.Long
with value @@CamelMagicValue@@
due to java.lang.NumberFormatException: For input string: "@@CamelMagicValue@@"
{code}
Affects any kamelet with optional properties of type long, int, double, float,
short, or byte.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)