diff options
author | Martin Polden <mpolden@mpolden.no> | 2018-07-04 14:54:03 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2018-07-04 14:54:21 +0200 |
commit | e7351549d1fef0179c5cc5957047734c168006ad (patch) | |
tree | 9e9d80f17c53767916ab3faffaa61c5806930376 | |
parent | 16e0031f69d90b2628fc5b092b9f3ed5eca351af (diff) |
Use try-with-resources
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java index a81c4adcb2e..2f9703b91e1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java @@ -26,12 +26,13 @@ import java.util.zip.ZipOutputStream; */ public class ApplicationPackageBuilder { - private String upgradePolicy = null; - private Environment environment = Environment.prod; - private String globalServiceId = null; private final StringBuilder environmentBody = new StringBuilder(); private final StringBuilder validationOverridesBody = new StringBuilder(); private final StringBuilder blockChange = new StringBuilder(); + + private String upgradePolicy = null; + private Environment environment = Environment.prod; + private String globalServiceId = null; private String athenzIdentityAttributes = null; private String searchDefinition = "search test { }"; @@ -145,8 +146,7 @@ public class ApplicationPackageBuilder { public ApplicationPackage build() { ByteArrayOutputStream zip = new ByteArrayOutputStream(); - ZipOutputStream out = new ZipOutputStream(zip); - try { + try (ZipOutputStream out = new ZipOutputStream(zip)) { out.putNextEntry(new ZipEntry("deployment.xml")); out.write(deploymentSpec()); out.closeEntry(); @@ -158,10 +158,6 @@ public class ApplicationPackageBuilder { out.closeEntry(); } catch (IOException e) { throw new UncheckedIOException(e); - } finally { - try { - out.close(); - } catch (IOException ignored) {} } return new ApplicationPackage(zip.toByteArray()); } |