Skip to content

Commit a4a67b7

Browse files
authored
testing: minor lint-suggested improvements (grpc#9259)
Use for-each and Lists.reverse() instead of classic for
1 parent 9cebe0a commit a4a67b7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

testing/src/main/java/io/grpc/testing/GrpcCleanupRule.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.common.annotations.VisibleForTesting;
2323
import com.google.common.base.Stopwatch;
2424
import com.google.common.base.Ticker;
25+
import com.google.common.collect.Lists;
2526
import io.grpc.ExperimentalApi;
2627
import io.grpc.ManagedChannel;
2728
import io.grpc.Server;
@@ -170,8 +171,8 @@ protected void after() {
170171

171172
InterruptedException interrupted = null;
172173
if (!abruptShutdown) {
173-
for (int i = resources.size() - 1; i >= 0; i--) {
174-
resources.get(i).cleanUp();
174+
for (Resource resource : Lists.reverse(resources)) {
175+
resource.cleanUp();
175176
}
176177

177178
for (int i = resources.size() - 1; i >= 0; i--) {
@@ -190,8 +191,8 @@ protected void after() {
190191
}
191192

192193
if (!resources.isEmpty()) {
193-
for (int i = resources.size() - 1; i >= 0; i--) {
194-
resources.get(i).forceCleanUp();
194+
for (Resource resource : Lists.reverse(resources)) {
195+
resource.forceCleanUp();
195196
}
196197

197198
try {

0 commit comments

Comments
 (0)