From 0edb24c72f8b861c53ea7956901a7894d39806b3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 30 Apr 2026 18:36:28 -0700 Subject: [PATCH] Reduce flakiness in io.opentelemetry.javaagent.instrumentation.grpc.v1_6.GrpcTest.clientCallAfterServerCompleted() Automated fix attempt based on Develocity flaky-test analysis. --- .../grpc/v1_6/AbstractGrpcTest.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java index 00518a652b1d..7d8c814fc7c6 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java @@ -1508,12 +1508,16 @@ public void sayHello( executor.execute( () -> { - try { - backendStub.sayHello(request); - } catch (Throwable t) { - error.set(t); - } - clientCallDone.countDown(); + // Execute in ROOT context to avoid cancelled context propagation + io.grpc.Context.ROOT.run( + () -> { + try { + backendStub.sayHello(request); + } catch (Throwable t) { + error.set(t); + } + clientCallDone.countDown(); + }); }); } })) @@ -1533,7 +1537,9 @@ public void sayHello( // for the two cases due to lack of context propagation in the library case, but that isn't what // we're testing here. - clientCallDone.await(10, SECONDS); + assertThat(clientCallDone.await(10, SECONDS)) + .as("client call should complete within timeout") + .isTrue(); assertThat(error).hasValue(null); }