From cc487aa2ac175cd2700761d41290d191aea9165c Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Mon, 9 Nov 2026 11:53:46 -0600 Subject: [PATCH] Fix flaky replaceConnectionAfterGoAway Make sure that the pipeline modification finishes before we write and flush the GOAWAY --- .../net/PooledH2ConnectionFactoryTest.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/PooledH2ConnectionFactoryTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/PooledH2ConnectionFactoryTest.java index 6f9b2bf37..9bc106244 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/PooledH2ConnectionFactoryTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/PooledH2ConnectionFactoryTest.java @@ -203,16 +203,18 @@ class PooledH2ConnectionFactoryTest { /// A future that completes once the factory has seen a GOAWAY on `connection` private static CompletableFuture goAwayRead(final Channel connection) { final CompletableFuture goAwayRead = new CompletableFuture<>(); - connection.pipeline().addAfter(connection.pipeline().context(Http2MultiplexHandler.class).name(), null, - new ChannelInboundHandlerAdapter() { - @Override - public void channelRead(final ChannelHandlerContext ctx, final Object msg) { - ctx.fireChannelRead(msg); - if (msg instanceof Http2GoAwayFrame) { - goAwayRead.complete(null); - } - } - }); + connection.eventLoop().submit(() -> connection.pipeline() + .addAfter(connection.pipeline().context(Http2MultiplexHandler.class).name(), null, + new ChannelInboundHandlerAdapter() { + @Override + public void channelRead(final ChannelHandlerContext ctx, final Object msg) { + ctx.fireChannelRead(msg); + if (msg instanceof Http2GoAwayFrame) { + goAwayRead.complete(null); + } + } + })) + .syncUninterruptibly(); return goAwayRead; } }