File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
commons-vfs2/src/test/java/org/apache/commons/vfs2/impl Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -281,14 +281,15 @@ public void testThreadSafety() throws Exception {
281281 if (!exceptions .isEmpty ()) {
282282 final StringBuilder exceptionMsg = new StringBuilder ();
283283 final StringBuilderWriter writer = new StringBuilderWriter (exceptionMsg );
284- final PrintWriter printWriter = new PrintWriter (writer );
285- for (final Throwable t : exceptions ) {
286- printWriter .write (t .getMessage ());
287- printWriter .write ('\n' );
288- t .printStackTrace (printWriter );
289- printWriter .write ('\n' );
284+ try (PrintWriter printWriter = new PrintWriter (writer )) {
285+ for (final Throwable t : exceptions ) {
286+ printWriter .write (t .getMessage ());
287+ printWriter .write ('\n' );
288+ t .printStackTrace (printWriter );
289+ printWriter .write ('\n' );
290+ }
291+ printWriter .flush ();
290292 }
291- printWriter .flush ();
292293 assertTrue (exceptions .size () + " threads failed: " + exceptionMsg , exceptions .isEmpty ());
293294 }
294295 }
You can’t perform that action at this time.
0 commit comments