gnodet opened a new pull request, #24475:
URL: https://github.com/apache/camel/pull/24475

   ## Summary
   
   _Claude Code on behalf of gnodet_
   
   Fix the 34% flaky rate of `ThemeTest` reported on the [Develocity 
dashboard](https://develocity.apache.org/scans/tests?search.rootProjectNames=camel&tests.sortField=FLAKY).
   
   ### Root Cause
   
   `Theme.engine()` used `StyleEngine.loadStylesheet()` which internally loads 
CSS resources via `StyleEngine.class.getClassLoader()`. Under parallel test 
execution (enabled by `camel.surefire.parallel=true` in the DSL parent POM), 
the StyleEngine's classloader (from the tamboui-css JAR) can diverge from the 
project's classloader, causing intermittent "resource not found" failures. When 
CSS loading fails, the engine falls back to built-in defaults — the dark theme 
tests still pass (fallback values match the dark CSS values), but the light 
theme test fails because `Color.LIGHT_GREEN` ≠ `Color.rgb(0x00, 0x77, 0x00)`.
   
   ### Fix
   
   - **Load CSS via Theme's own classloader**: Read CSS content using 
`Theme.class.getClassLoader().getResourceAsStream()` (with a 
thread-context-classloader fallback) and pass it to 
`StyleEngine.addStylesheet()` instead of `StyleEngine.loadStylesheet()`. This 
guarantees access to project resources regardless of classloader hierarchy.
   - **Synchronize `accent()` and `zebra()`**: These two methods were the only 
unsynchronized Theme accessors, creating a potential for concurrent render 
tests to interfere with state between `engine()` return and `resolve()` call.
   - **Use `ConcurrentHashMap` for style cache**: Defensive measure replacing 
the `HashMap`.
   
   ### Prior Fix Attempts (both insufficient)
   
   - `cc39bab`: Added `testMode` flag and kept StyleEngine alive across resets
   - `be06caeb` (CAMEL-23912): Added `@Isolated`, reset engine in 
`resetForTesting()`, load only active stylesheet
   
   Both addressed symptoms (static state leaks) but not the root cause 
(classloader mismatch in CSS loading).
   
   ### Validation
   
   - Ran full module tests (519 tests) with `parallel=true` and 
`parallel.factor=4` — 10/10 runs passed with 0 failures.
   - ThemeTest alone: 20/20 runs passed.


-- 
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]

Reply via email to