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

   ## Summary
   
   Fixes a race condition in `MailMimeDecodeHeadersTest` that caused 
intermittent failures on slow CI machines.
   
   ## Root Cause
   
   `Mailbox.clearAll()` was called at the **start of each test method body**, 
_after_ the `CamelContext` had already started the POP3 consumer routes (with 
`initialDelay=100ms`). On slow CI machines, the first POP3 poll could fire 
within that 100ms window — before `clearAll()` ran — picking up stale messages 
left by the previous test method.
   
   This produced a flaky `AssertionError` where the mock received an unexpected 
extra message (from the prior test) causing an unexpected message count or a 
wrong header value.
   
   ## Fix
   
   1. **Move `Mailbox.clearAll()` to `setupResources()`** — this hook runs 
before `CamelContext` starts (called by `CamelTestSupport.setUp()` before 
`startCamelContext()`), so the mailboxes are guaranteed empty when the first 
POP3 poll fires.
   
   2. **Add `delete=true` to both POP3 URIs** — messages are deleted from the 
mailbox after they are consumed, so they cannot survive a poll and appear in a 
subsequent test method (defence-in-depth).
   
   ## Testing
   
   Both tests pass locally. The fix is structurally equivalent to the 
established pattern used by other tests in this module (e.g. 
`MailSearchTermTest`, `MailMaxMessagesPerPollTest`, etc.).
   
   ---
   _Claude Sonnet 4.6 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]

Reply via email to