use try with resources

This commit is contained in:
Stefan Spieker committed 2021-06-11 22:34:07 +02:00
1 parent 862acf3e2d
commit 7fd6191ed2
1 file changed
+2 -7
+2 -7
View File
@@ -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<PluginWrapper> cycle)
throws hudson.util.CyclicGraphDetector.CycleDetectedException {
protected void reactOnCycle(PluginWrapper q, List<PluginWrapper> 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);