diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java index f7d617abba..830915ecc3 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java @@ -111,15 +111,14 @@ public void test3() throws Exception { } private void copy(File src, File dst) throws IOException { - InputStream in = new FileInputStream(src); - OutputStream out = new FileOutputStream(dst); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); + try (InputStream in = new FileInputStream(src); + OutputStream out = new FileOutputStream(dst);) { + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } } - in.close(); - out.close(); } }