--- a/jdk/test/java/io/FileOutputStream/AtomicAppend.java Tue Mar 01 12:03:44 2011 +0000
+++ b/jdk/test/java/io/FileOutputStream/AtomicAppend.java Tue Mar 01 15:05:32 2011 -0800
@@ -47,12 +47,12 @@
for (int i = 0; i < nThreads; i++)
es.execute(new Runnable() { public void run() {
try {
- FileOutputStream s = new FileOutputStream(file, true);
- for (int j = 0; j < 1000; j++) {
- s.write((int) 'x');
- s.flush();
+ try (FileOutputStream s = new FileOutputStream(file, true)) {
+ for (int j = 0; j < 1000; j++) {
+ s.write((int) 'x');
+ s.flush();
+ }
}
- s.close();
} catch (Throwable t) { unexpected(t); }}});
es.shutdown();
es.awaitTermination(10L, TimeUnit.MINUTES);