Skip to content

CAMEL-27103: camel-spring-boot - typeConverterStatisticsEnabled now enables the statistics - #2114

Merged
Croway merged 1 commit into
apache:mainfrom
lobtx:CAMEL-27103-typeconverter-statistics
Nov 19, 2026
Merged

Croway merged 1 commit into
apache:mainfrom
lobtx:CAMEL-27103-typeconverter-statistics

Conversation

@lobtx

@lobtx lobtx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up of 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

…nables the statistics

Same issue as fixed for Camel Main in apache/camel#30303: the type converter
registry is created when the CamelContext is built, and its statistics cannot
be enabled afterwards (Camel 4.7). CamelAutoConfiguration.doConfigureCamelContext
calls camelContext.build() before DefaultConfigurationConfigurer.configure(),
so camel.main.type-converter-statistics-enabled=true had no effect.

The option is now set on the context before build(); config.getMain() is
already bound at that point.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Croway

Croway commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix!

@Croway
Croway merged commit 548ee11 into apache:main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants