From a4a67b7fc7242185ae6e9232faffbe4127ebd2b1 Mon Sep 17 00:00:00 2001 From: Sergii Tkachenko Date: Fri, 10 Jun 2022 15:42:51 -0700 Subject: [PATCH] testing: minor lint-suggested improvements (#9259) Use for-each and Lists.reverse() instead of classic for --- .../src/main/java/io/grpc/testing/GrpcCleanupRule.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java index fb11152570..f518dcb9e5 100644 --- a/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java +++ b/testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Stopwatch; import com.google.common.base.Ticker; +import com.google.common.collect.Lists; import io.grpc.ExperimentalApi; import io.grpc.ManagedChannel; import io.grpc.Server; @@ -170,8 +171,8 @@ public final class GrpcCleanupRule extends ExternalResource { InterruptedException interrupted = null; if (!abruptShutdown) { - for (int i = resources.size() - 1; i >= 0; i--) { - resources.get(i).cleanUp(); + for (Resource resource : Lists.reverse(resources)) { + resource.cleanUp(); } for (int i = resources.size() - 1; i >= 0; i--) { @@ -190,8 +191,8 @@ public final class GrpcCleanupRule extends ExternalResource { } if (!resources.isEmpty()) { - for (int i = resources.size() - 1; i >= 0; i--) { - resources.get(i).forceCleanUp(); + for (Resource resource : Lists.reverse(resources)) { + resource.forceCleanUp(); } try {