From b85dc6807658700a9df671359bb1f1a2b3ba282e Mon Sep 17 00:00:00 2001 From: Laurent Goujon Date: Mon, 14 Feb 2022 14:49:09 -0800 Subject: [PATCH 1/2] testing: fix GrpcCleanupRule issue when retrying tests Fix an issue in GrpcCleanupRule when tests are retried and the teardown() method is invoked multiple times, causing Stopwatch instance to throw an IllegalStateException. fixes grpc/grpc-java#8917. --- testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java index 329d051ceb3..360c0662ccc 100644 --- a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java +++ b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java @@ -175,6 +175,7 @@ public void evaluate() throws Throwable { * Releases all the registered resources. */ private void teardown() { + stopwatch.reset(); stopwatch.start(); if (firstException == null) { From 4bfdc3673626558e84c6a6143a39509f571b27ef Mon Sep 17 00:00:00 2001 From: Laurent Goujon Date: Mon, 14 Feb 2022 23:31:28 -0800 Subject: [PATCH 2/2] Reset firstException before test is evaluated --- testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java index 360c0662ccc..47a3416d4d3 100644 --- a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java +++ b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java @@ -149,6 +149,7 @@ public Statement apply(final Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { + firstException = null; try { base.evaluate(); } catch (Throwable t) {