mayurbm commented on PR #25771: URL: https://github.com/apache/camel/pull/25771#issuecomment-5432725651
Hi @davsclaus, thank you for the excellent architectural feedback — you are completely right. **Updated to the sentinel approach as you suggested.** Instead of per-call-site null guards, `DefaultCamelContextExtension.resetTypeConverter()` now installs a `StoppedTypeConverter` sentinel instead of setting the field to `null`. Every method on the sentinel throws `IllegalStateException` with a clear message: ``` IllegalStateException: TypeConverter is not available because the CamelContext has been stopped (context not started, stopped, or not initialized) ``` This fixes all ~200 unguarded `getTypeConverter()` call sites across `core/` in a single change — no scattered null-guards to maintain or forget. The per-call-site guards in `AbstractExchange.getIn()` and `getOut()` from the initial commit have been reverted — no longer needed. `resetTypeConverter()`'s existing purpose (CamelContext restart-in-place via `stop()`/`start()`) is preserved: `getOrCreateTypeConverter()` still creates a fresh converter on the next `start()` call. **Regarding the pom.xml concern:** removed the `assertj-core`/`mockito-core` additions from `camel-support/pom.xml`. The new test is in `camel-core` (where `DefaultCamelContext` is available) which already has AssertJ — no Mockito needed. **Changes: 3 files** - `DefaultCamelContextExtension.java` — sentinel `StoppedTypeConverter` inner class + `resetTypeConverter()` installs it - `AbstractExchange.java` — reverted to original (no per-call-site guards) - `camel-core/.../StoppedTypeConverterTest.java` — 2 tests: sentinel is non-null after stop, sentinel throws `IllegalStateException` Local validation: - `mvn formatter:format impsort:sort` — no changes needed - `StoppedTypeConverterTest`: Tests run: 2, Failures: 0 -- 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]
