Skip to content

Commit 1176818

Browse files
committed
Close output stream after last iteration.
1 parent e1d11b2 commit 1176818

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

tests/src/main/java/com/squareup/luhnybin/Main.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public void run() {
9393
long[] times = new long[iterations];
9494

9595
for (int i = 0; i < iterations; i++) {
96+
final boolean lastIteration = i == iterations - 1;
97+
9698
long iterationStart = System.nanoTime();
9799

98100
// Write in the background. Writing can block if the buffer fills up.
@@ -101,6 +103,7 @@ public void run() {
101103
try {
102104
bout.writeTo(out);
103105
out.flush();
106+
if (lastIteration) out.close();
104107
} catch (IOException e) {
105108
e.printStackTrace();
106109
System.exit(1);
@@ -130,8 +133,6 @@ public void testFailed(TestCase test, String actualInput) {
130133
times[i] = (System.nanoTime() - iterationStart) / 1000;
131134
}
132135

133-
out.close();
134-
135136
long elapsed = (System.nanoTime() - start) / 1000000;
136137

137138
System.out.println();
-404 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)