Federico Mariani created CAMEL-27115:
----------------------------------------
Summary: camel-core - log a WARN when type converters on the
classpath are not loaded (TypeConverter file with loadTypeConverters off, fat
jar without the camel-base loader)
Key: CAMEL-27115
URL: https://issues.apache.org/jira/browse/CAMEL-27115
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Federico Mariani
Camel does not load some type converters that are on the classpath, and logs
nothing about it. The failure shows up later as a missing conversion.
1. A {{META-INF/services/org/apache/camel/TypeConverter}} file (the package or
class names of {{@Converter}} classes without a generated loader) is read only
when {{loadTypeConverters}} is on, which is off by default. With the default
the file is ignored:
{code:java}
// META-INF/services/org/apache/camel/TypeConverter lists com.foo.converters
CamelContext context = new DefaultCamelContext();
context.start();
context.getTypeConverter().convertTo(MyBean.class, "a:b"); // null, no log line
{code}
2. The core converters of camel-base are found only through the
{{META-INF/services/org/apache/camel/TypeConverterLoader}} file of camel-base.
Every Camel JAR has a file with that name. A fat jar built without
{{camel:prepare-fatjar}} (or without merging these files) keeps one of them,
and the core converters are not loaded. Routes then fail with errors such as
{{No type converter available to convert from type: java.lang.String to the
required type: java.time.Duration}} on {{timer:t?delay=0}}, with nothing that
points to the packaging.
Expected: a WARN on startup, once per CamelContext:
* for 1, with the location of the file and the ways to load it
({{camel.main.loadTypeConverters=true}}, {{@Converter(generateLoader = true)}},
{{addTypeConverters}}). No WARN when {{loadTypeConverters}} or a base package
scan is on, or when the runtime discovers the converters at build time (Camel
Quarkus).
* for 2, when no loader file lists
{{org.apache.camel.converter.CamelBaseBulkConverterLoader}}, naming the
{{prepare-fatjar}} goal of the camel-maven-plugin.
The loading behaviour does not change.
_Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)