From bfb970ce031ec319b3cb6c03a44dfc2d16e87ce5 Mon Sep 17 00:00:00 2001 From: Laurent Goujon Date: Tue, 15 Feb 2022 12:52:24 -0800 Subject: [PATCH] testing: fix GrpcCleanupRule issue when retrying tests (#8918) 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 #8917. --- testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java index 329d051ceb..47a3416d4d 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 final class GrpcCleanupRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { + firstException = null; try { base.evaluate(); } catch (Throwable t) { @@ -175,6 +176,7 @@ public final class GrpcCleanupRule implements TestRule { * Releases all the registered resources. */ private void teardown() { + stopwatch.reset(); stopwatch.start(); if (firstException == null) {