Skip to content

Commit

Permalink
Merge pull request #5568 from StefanSpieker/pluginmanager_minor
Browse files Browse the repository at this point in the history
Minor Refactoring: Use try with resources in PluginManager
  • Loading branch information
res0nance authored Jun 20, 2021
2 parents edc6e13 + 7fd6191 commit e4ca1f3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
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;
Expand Down Expand Up @@ -482,8 +481,7 @@ private void addTo(List<Dependency> dependencies, List<PluginWrapper> r) {
}

@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) {
Expand Down Expand Up @@ -1071,8 +1069,7 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException {
}

/*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);
Expand All @@ -1082,8 +1079,6 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException {
}
} 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);
Expand Down

0 comments on commit e4ca1f3

Please sign in to comment.