Browse files

Close output stream after last iteration.

  • Loading branch information...
1 parent e1d11b2 commit 117681827c024a8e173cbd88f07205fc84e683dd @crazybob committed Nov 15, 2011
View
5 tests/src/main/java/com/squareup/luhnybin/Main.java
@@ -93,6 +93,8 @@ public void run() {
long[] times = new long[iterations];
for (int i = 0; i < iterations; i++) {
+ final boolean lastIteration = i == iterations - 1;
+
long iterationStart = System.nanoTime();
// Write in the background. Writing can block if the buffer fills up.
@@ -101,6 +103,7 @@ public void run() {
try {
bout.writeTo(out);
out.flush();
+ if (lastIteration) out.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
@@ -130,8 +133,6 @@ public void testFailed(TestCase test, String actualInput) {
times[i] = (System.nanoTime() - iterationStart) / 1000;
}
- out.close();
-
long elapsed = (System.nanoTime() - start) / 1000000;
System.out.println();
View
BIN tests/target/luhnybin-1.0-SNAPSHOT.jar
Binary file not shown.

0 comments on commit 1176818

Please sign in to comment.