diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index 49999085be2..551e62588e3 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -1060,6 +1060,9 @@ public class CoreContainer { log.warn("Exception while closing auditlogger plugin.", e); } + if(packageLoader != null){ + org.apache.lucene.util.IOUtils.closeWhileHandlingException(packageLoader); + } org.apache.lucene.util.IOUtils.closeWhileHandlingException(loader); // best effort } diff --git a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java index e82a07144f5..88e4e0fb7c8 100644 --- a/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java +++ b/solr/core/src/java/org/apache/solr/pkg/PackageLoader.java @@ -36,17 +36,18 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.apache.solr.common.MapWriter; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.util.IOUtils; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrResourceLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.lucene.util.IOUtils.closeWhileHandlingException; + /** * The class that holds a mapping of various packages and classloaders */ -public class PackageLoader implements AutoCloseable { +public class PackageLoader implements Closeable { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final CoreContainer coreContainer; @@ -96,7 +97,7 @@ public class PackageLoader implements AutoCloseable { //other classes are holding to a reference to this objecec // they should know that this is removed p.markDeleted(); - IOUtils.closeQuietly((Closeable) p); + closeWhileHandlingException(p); } } } @@ -144,7 +145,7 @@ public class PackageLoader implements AutoCloseable { /** * represents a package definition in the packages.json */ - public class Package implements AutoCloseable { + public class Package implements Closeable { final String name; final Map myVersions = new ConcurrentHashMap<>(); private List sortedVersions = new CopyOnWriteArrayList<>(); @@ -181,7 +182,7 @@ public class PackageLoader implements AutoCloseable { sortedVersions.remove(s); Version removed = myVersions.remove(s); if (removed != null) { - IOUtils.closeQuietly((Closeable) removed); + closeWhileHandlingException(removed); } } } @@ -226,11 +227,11 @@ public class PackageLoader implements AutoCloseable { } @Override - public void close() throws Exception { + public void close() throws IOException { for (Version v : myVersions.values()) v.close(); } - public class Version implements MapWriter, AutoCloseable { + public class Version implements MapWriter, Closeable { private final Package parent; private SolrResourceLoader loader; @@ -274,9 +275,9 @@ public class PackageLoader implements AutoCloseable { } @Override - public void close() throws Exception { + public void close() throws IOException { if (loader != null) { - loader.close(); + closeWhileHandlingException(loader); } } } @@ -293,7 +294,7 @@ public class PackageLoader implements AutoCloseable { } @Override - public void close() throws Exception { - for (Package p : packageClassLoaders.values()) p.close(); + public void close() { + for (Package p : packageClassLoaders.values()) closeWhileHandlingException(p); } } diff --git a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java index c07bbc3da28..4ff0f7afe20 100644 --- a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java +++ b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.concurrent.Callable; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.lucene.util.LuceneTestCase; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -61,7 +60,6 @@ import static org.apache.solr.filestore.TestDistribPackageStore.readFile; @LogLevel("org.apache.solr.pkg.PackageLoader=DEBUG;org.apache.solr.pkg.PackageAPI=DEBUG") //@org.apache.lucene.util.LuceneTestCase.AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-13822") // leaks files -@LuceneTestCase.SuppressFileSystems("WindowsFS") public class TestPackages extends SolrCloudTestCase { @Test