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

Claus Ibsen resolved CAMEL-27103.
---------------------------------
    Resolution: Fixed

Fixed by https://github.com/apache/camel/pull/30303 (merged as f04cf99201be). 
Camel Main now applies camel.main.typeConverterStatisticsEnabled before the 
CamelContext is built. Thanks lobtx!

_Claude Code on behalf of davsclaus_

> camel-main - typeConverterStatisticsEnabled may have no effect, as the 
> context is built before the option is applied
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27103
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27103
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-main
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> *Needs investigation.* This comes from reading the code during a review of PR 
> #30261; it has not been reproduced at runtime.
> The type converter statistics flag is read once, when the type converter 
> registry is created:
> * {{CoreTypeConverterRegistry(boolean statisticsEnabled)}} picks 
> {{TypeConverterStatistics}} or {{NoopTypeConverterStatistics}} in its 
> constructor, and the {{statistics}} field is final.
> * {{AbstractCamelContext.doBuild()}} creates the type converter eagerly 
> ({{eagerCreateTypeConverter()}} returns true).
> * {{AbstractCamelContext.setTypeConverterStatisticsEnabled}} only stores the 
> flag; it does not update an existing registry.
> In camel-main, {{BaseMainSupport.postProcessCamelContext}} calls 
> {{camelContext.build()}} first, and only later calls 
> {{autoconfigure(camelContext)}}. That leads to 
> {{DefaultConfigurationConfigurer}}, which calls 
> {{camelContext.setTypeConverterStatisticsEnabled(config.isTypeConverterStatisticsEnabled())}}.
>  If that order holds, {{camel.main.typeConverterStatisticsEnabled=true}} is 
> set after the registry already exists, so the statistics stay disabled (the 
> noop version).
> To check:
> * Run a Camel Main app with 
> {{camel.main.typeConverterStatisticsEnabled=true}} and look at the statistics 
> (JMX {{ManagedTypeConverterRegistryMBean}} or 
> {{TypeConverterRegistry.getStatistics()}}).
> * Check Spring Boot and Quarkus too: they may set the option at a different 
> point.
> * If it is confirmed, either apply the option before {{build()}}, or let the 
> registry switch its statistics after it is created.
> Related: the Javadoc of {{CamelContext.setTypeConverterStatisticsEnabled}} 
> (reworded in PR #30261) should say that the option must be set before the 
> context is built, not only before it is started.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to