diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 2939186379..256a4e29ef 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -110,7 +110,6 @@ import javax.servlet.ServletException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; -import java.io.Closeable; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; @@ -482,8 +481,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } @Override - protected void reactOnCycle(PluginWrapper q, List cycle) - throws hudson.util.CyclicGraphDetector.CycleDetectedException { + protected void reactOnCycle(PluginWrapper q, List cycle) { LOGGER.log(Level.SEVERE, "found cycle in plugin dependencies: (root=" + q + ", deactivating all involved) " + cycle.stream().map(Object::toString).collect(Collectors.joining(" -> "))); for (PluginWrapper pluginWrapper : cycle) { @@ -1071,8 +1069,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } /*package*/ static @CheckForNull Manifest parsePluginManifest(URL bundledJpi) { - try { - URLClassLoader cl = new URLClassLoader(new URL[]{bundledJpi}); + try (URLClassLoader cl = new URLClassLoader(new URL[]{bundledJpi})){ InputStream in=null; try { URL res = cl.findResource(PluginWrapper.MANIFEST_FILENAME); @@ -1082,8 +1079,6 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } } finally { Util.closeAndLogFailures(in, LOGGER, PluginWrapper.MANIFEST_FILENAME, bundledJpi.toString()); - if (cl instanceof Closeable) - ((Closeable)cl).close(); } } catch (IOException e) { LOGGER.log(WARNING, "Failed to parse manifest of "+bundledJpi, e);