gnodet commented on PR #31253:
URL: https://github.com/apache/camel/pull/31253#issuecomment-7347823100
> _Hermès on behalf of gnodet_
**Follow-up fix pushed:** the previous commit left `recorder.isStarted() =
false` in the JFR tests.
**Root cause** (traced through the lifecycle):
1. `KameletMain.createCamelContext()` sets
`FlightRecorderStartupStepRecorder` with `recording=true` and calls
`addInitialPropertyIfAbsent("camel.main.startupRecorder", "jfr")`.
2. `postProcessCamelContext()` calls `configureStartupRecorder()` **before**
`camelContext.build()`. The existing commit kept the JFR recorder but then
called
`fr.setRecording(mainConfigurationProperties.isStartupRecorderRecording())` —
which is `false` at this point because `mainConfigurationProperties` hasn't
been populated from properties yet (that happens later in `autoconfigure()`).
3. `camelContext.build()` then calls `startupStepRecorder.start()` →
`doStart()` → `isRecording() = false` → `rec.start()` is never called.
**Fix:** when the JFR recorder was pre-installed (detected by its class name
prefix), skip the `setRecording()`, `setRuntimeEnabled()`,
`setStartupRecorderDuration()`, and `setRecordingProfile()` calls in
`configureStartupRecorder()`. The recorder was already configured correctly by
whoever installed it. `camelContext.build()` can then start the recorder with
the right settings.
The property overrides from
`addInitialPropertyIfAbsent("camel.main.startupRecorderRecording", "true")`
still serve their purpose: they ensure the `ProfileConfigurer` dev-profile
default (`startupRecorder=backlog`) is suppressed by being present in
`autoConfiguredProperties` when `autoconfigure()` runs.
**Verified:** all 4 tests in `KameletMainInitialPropertyTest` pass locally.
--
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]