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);
|
hook.setLastModified(time);
|
||||||
hooks.put(name, hook);
|
hooks.put(name, hook);
|
||||||
} else if ("jar".equals(protocol)) {
|
} else if ("jar".equals(protocol)) {
|
||||||
InputStream in = url.openStream();
|
try (InputStream in = url.openStream()) {
|
||||||
try {
|
|
||||||
hook = File.createTempFile("hook_", ".sh");
|
hook = File.createTempFile("hook_", ".sh");
|
||||||
cleanup.add(hook);
|
cleanup.add(hook);
|
||||||
FileOutputStream out = new FileOutputStream(hook);
|
try (FileOutputStream out = new FileOutputStream(hook)) {
|
||||||
try {
|
|
||||||
ByteStreams.copy(in, out);
|
ByteStreams.copy(in, out);
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
in.close();
|
|
||||||
}
|
}
|
||||||
hook.setExecutable(true);
|
hook.setExecutable(true);
|
||||||
hooks.put(name, hook);
|
hooks.put(name, hook);
|
||||||
|
|||||||
Reference in New Issue
Block a user