Skip to content

Commit d7c142f

Browse files
gnodetclaude
authored andcommitted
Fix thread-safety bug in TestSpanHandler causing flaky tracing tests (#2971)
* Increase Awaitility timeout in tracing tests from 5s to 10s The 5-second timeout introduced in #2962 is still not sufficient for CI environments under load. Tracing tests like testThatNewSpanIsCreatedOnClientTimeout continue to fail with ConditionTimeoutException at the 5-second mark. Increase all Awaitility timeouts to 10 seconds across all tracing test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Increase Awaitility timeout in tracing tests from 10s to 30s Even the 10s timeout was observed failing in CI (run 23065827441). Analysis of recent builds shows the 5s ConditionTimeoutException occurs in virtually every CI run. Use 30s to provide sufficient headroom for loaded CI environments while still catching genuine hangs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix TestSpanHandler thread-safety and revert timeout increase TestSpanHandler.SPANS used a plain ArrayList, which is not thread-safe. Client and server spans are added from different threads, so concurrent ArrayList.add() calls can lose elements and size() may return stale values due to JMM visibility. Change to CopyOnWriteArrayList which provides proper thread-safety. Writes (span additions) are infrequent while reads (Awaitility polling) are frequent, making COW the ideal choice. Revert the Awaitility timeout back to 5s since the thread-safety fix addresses the root cause of the flaky failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit e6ce6d6)
1 parent 9a756ed commit d7c142f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

systests/tracing/src/test/java/org/apache/cxf/systest/brave/TestSpanReporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
*/
1919
package org.apache.cxf.systest.brave;
2020

21-
import java.util.ArrayList;
2221
import java.util.List;
22+
import java.util.concurrent.CopyOnWriteArrayList;
2323

2424
import zipkin2.Span;
2525
import zipkin2.reporter.Reporter;
2626

2727
public class TestSpanReporter implements Reporter<Span> {
28-
private static final List<Span> SPANS = new ArrayList<>(12);
28+
private static final List<Span> SPANS = new CopyOnWriteArrayList<>();
2929

3030
@Override
3131
public void report(Span span) {

0 commit comments

Comments
 (0)