HookTestCase: Use auto-closeable streams
Change-Id: Icc9ad197e95ee982c119b18c197c095cd43f41fc
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user