You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Flaky test: InboxMiddlewareTest hits ConcurrentModificationException on the mock's request list #4132
InboxMiddlewareTest.notificationReachesModelRequestUnderRealScheduling fails intermittently on CI:
java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1604)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
at io.agentscope.harness.agent.middleware.InboxMiddlewareTest.notificationReachesModelRequestUnderRealScheduling(InboxMiddlewareTest.java:311)
MockModel.recordedMessages is a plain ArrayList, appended in stream(...) from whichever
thread issues the model call. The test reads it through getRecordedMessages() right after the
turn returns, while the background memory-maintenance turn may still be issuing a model call —
the test's own comment says so:
Background memory maintenance reuses this model for consolidation requests after the call
returns, so the last recorded request races that pipeline under load
That append invalidates the iterator the test is draining.
To Reproduce
No threads required — hold an iterator, record one more request, then keep draining:
2 of the 6 most recent failed Java CI with Maven runs hit this test (43013023879, 43013520954). The same commits passed the windows job, so it is load-dependent.
Locally (JDK 17, Windows) 12/12 runs pass; the CI load is what exposes it.
Expected
Reading the recorded requests must not throw because another thread recorded a request.
Fix
Record into a CopyOnWriteArrayList (append-only, read-mostly) and pin the interleaving with a
test that records a request midway through an iteration; against the old ArrayList it throws the
same ConcurrentModificationException.
Activity