From 784fa0add77a3e473e2cdbdcc27b3ed076678565 Mon Sep 17 00:00:00 2001 From: Thejasvi Voniadka Date: Tue, 28 Jun 2022 01:55:17 +0000 Subject: [PATCH] 8282036: Change java/util/zip/ZipFile/DeleteTempJar.java to stop HttpServer cleanly in case of exceptions Reviewed-by: jpai, alanb, dfuchs --- .../java/util/zip/ZipFile/DeleteTempJar.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java b/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java index 58cc830b4aa..7ac4f2616c3 100644 --- a/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java +++ b/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,16 +72,19 @@ public class DeleteTempJar } } }); - server.start(); - URL url = new URL("jar:http://localhost:" + server.start(); + try { + URL url = new URL("jar:http://localhost:" + new Integer(server.getAddress().getPort()).toString() + "/deletetemp.jar!/"); - JarURLConnection c = (JarURLConnection)url.openConnection(); - JarFile f = c.getJarFile(); - check(f.getEntry("entry") != null); - System.out.println(f.getName()); - server.stop(0); + JarURLConnection c = (JarURLConnection)url.openConnection(); + JarFile f = c.getJarFile(); + check(f.getEntry("entry") != null); + System.out.println(f.getName()); + } finally { + server.stop(0); + } } //--------------------- Infrastructure ---------------------------