lobtx opened a new pull request, #2114: URL: https://github.com/apache/camel-spring-boot/pull/2114
# Description Follow-up of [CAMEL-27103](https://issues.apache.org/jira/browse/CAMEL-27103) and apache/camel#30303, which fixed the same issue in Camel Main. ## Problem `camel.main.type-converter-statistics-enabled=true` has no effect in Camel Spring Boot: `CamelContext.isTypeConverterStatisticsEnabled()` returns true, but the type converter registry keeps the noop statistics and the counters stay at 0. Since Camel 4.7 the statistics collector is chosen once, when the registry is created, which happens when the context is built. `CamelAutoConfiguration.doConfigureCamelContext` calls `camelContext.build()` before `DefaultConfigurationConfigurer.configure(camelContext, config.getMain())`, which applies the option, so it comes too late. ## Reproduction `TypeConverterStatisticsEnabledTest` fails on main with `expected: <1> but was: <0>`: @SpringBootTest(classes = { CamelAutoConfiguration.class }, properties = { "camel.main.type-converter-statistics-enabled = true" }) ... TypeConverterRegistry.Statistics statistics = context.getTypeConverterRegistry().getStatistics(); long before = statistics.getAttemptCounter(); context.getTypeConverter().convertTo(int.class, "123"); assertEquals(before + 1, statistics.getAttemptCounter()); ## Why it needs a fix The option is documented for Camel Main and Camel Spring Boot, but in Camel Spring Boot it silently does nothing. ## Fix `CamelAutoConfiguration.doConfigureCamelContext`: set the option on the context before `camelContext.build()`, next to `configureStartupRecorder`. `config.getMain()` is already bound by Spring at that point, so there is no need for the early lookup that Camel Main uses. Tested with the camel-spring-boot tests, and with a standalone Spring Boot 4.1.2 application (a timer route converting 10 bodies, counters read through JMX on the `DefaultTypeConverter` MBean): `AttemptCounter` was 0 before the fix and is 11 with it, with `application.properties` or with `CAMEL_MAIN_TYPECONVERTERSTATISTICSENABLED=true`; it stays at 0 without the option. AI tool used: Claude Code (Claude Opus 5.5), reviewed and checked by me. _Claude Code on behalf of lobtx_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
