Skip to content

Commit

Permalink
Don't fail on BrokenBarrierException
Browse files Browse the repository at this point in the history
If the barrier has been reset that means the test has already completed and we
don't care about node connection attempts and shouldn't throw an assertion error and fail
the test

Resolve elastic#105556
  • Loading branch information
arteam committed Feb 19, 2024
1 parent f65312e commit f49e252
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Semaphore;
Expand Down Expand Up @@ -266,7 +267,13 @@ public void onNodeDisconnected(DiscoveryNode node, Transport.Connection connecti
// connection attempts to node0 block indefinitely
final CyclicBarrier connectionBarrier = new CyclicBarrier(2);
try {
nodeConnectionBlocks.put(node0, () -> connectionBarrier.await(10, TimeUnit.SECONDS));
nodeConnectionBlocks.put(node0, () -> {
try {
connectionBarrier.await(10, TimeUnit.SECONDS);
} catch (BrokenBarrierException e) {
logger.warn("Broken barrier", e);
}
});
transportService.disconnectFromNode(node0);

// can still connect to another node without blocking
Expand Down

0 comments on commit f49e252

Please sign in to comment.