gnodet opened a new pull request, #25230: URL: https://github.com/apache/camel/pull/25230
## Summary _Claude Code on behalf of gnodet_ Fixes [CAMEL-24305](https://issues.apache.org/jira/browse/CAMEL-24305): `KafkaComponent` does not autowire a custom `KafkaClientFactory` bean when the component is registered via `addComponent()` (the path used by Spring Boot). ### Root Cause When a component is registered via `CamelContext.addComponent()`, the lifecycle order is: 1. `ServiceHelper.initService(component)` — calls `doBuild()` + `doInit()` 2. `postInitComponent()` — triggers autowiring via `LifecycleStrategySupport.doAutoWire()` Since `KafkaComponent.doInit()` was creating a `DefaultKafkaClientFactory` in step 1, the field was already non-null when autowiring checked it in step 2, and the custom factory was silently skipped. This is a regression from [CAMEL-17262](https://issues.apache.org/jira/browse/CAMEL-17262) (commit `74c5a4ad2a7`), which reintroduced the bug originally fixed in [CAMEL-16500](https://issues.apache.org/jira/browse/CAMEL-16500) (commit `5ae05407c02`). ### Fix - **KafkaComponent**: Move default `KafkaClientFactory` creation from `doInit()` to `doStart()`, giving the autowiring lifecycle strategy time to inject a custom factory before the default is created. This follows the same pattern used by `MapstructComponent` and `VertxHttpComponent`. - **KafkaEndpoint**: Restore the `DefaultKafkaClientFactory` fallback in `doBuild()` (originally from CAMEL-16500) for resilience when the endpoint builds before the component starts. ### Tests - Added `testKafkaComponentAutowiringViaAddComponent()` — exercises the `addComponent()` path with a custom `KafkaClientFactory` registered in the registry, verifying autowiring works - Added `testKafkaComponentDefaultFactoryWhenNoneRegistered()` — verifies the default factory is still created when no custom factory is available - Existing `testKafkaComponentAutowiring()` continues to pass (exercises the `getComponent()` path) - All 196 unit tests in `camel-kafka` pass with 0 failures 🤖 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]
