gnodet opened a new pull request, #29173:
URL: https://github.com/apache/camel/pull/29173
## Problem
`MonitorStartupTest` has a ~92% failure rate on CI because of two
independent bugs:
**1. Port race with parallel test forks**
`AvailablePortFinder.find()` probes a free port by opening a `ServerSocket`,
then closes it immediately and returns the port number. No lock is held between
the probe and Netty's bind — another test fork running in parallel can claim
the port in that window, causing `BindException` for the Netty server and
spurious test failures.
**2. Leaked `TuiWebServer` in `browserOnlyRefusesMcp`**
The test called `newServer()` but never `stop()` — the Netty
`EventLoopGroup`s and `ExecutorService` were initialized at construction and
leaked into subsequent tests.
## Fix
- Add `@Isolated` to the test class: JUnit 5's isolation guarantee
serialises the whole class against the rest of the suite, eliminating port
contention with parallel forks.
- Wrap `browserOnlyRefusesMcp` in `try/finally { server.stop(); }` to
release Netty resources even when the test throws (which it does, by design —
`serveBrowserOnly` checks the `--mcp` flag before starting the server, so
`stop()` is called on a never-started instance; `TuiWebServer.stop()` is safe
on an unstarted server).
The `browserOnlyServesUntilTheServerStops` test already correctly propagates
server startup failures through the `AtomicReference` failure check before
asserting on printer output.
---
_Hermes agent on behalf of gnodet_
--
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]