HookTestCase: Use auto-closeable streams

Change-Id: Icc9ad197e95ee982c119b18c197c095cd43f41fc
This commit is contained in:
David Pursehouse
2015-05-29 16:11:46 +09:00
parent 3ffbfb9754
commit b2efbf271f

View File

@@ -122,18 +122,12 @@ public abstract class HookTestCase extends LocalDiskRepositoryTestCase {
hook.setLastModified(time);
hooks.put(name, hook);
} else if ("jar".equals(protocol)) {
InputStream in = url.openStream();
try {
try (InputStream in = url.openStream()) {
hook = File.createTempFile("hook_", ".sh");
cleanup.add(hook);
FileOutputStream out = new FileOutputStream(hook);
try {
try (FileOutputStream out = new FileOutputStream(hook)) {
ByteStreams.copy(in, out);
} finally {
out.close();
}
} finally {
in.close();
}
hook.setExecutable(true);
hooks.put(name, hook);