SOLR-13822: FIle leakes fixed

This commit is contained in:
noble 2019-11-01 16:33:20 +11:00
parent 0dcd8603cb
commit 53b002f59d
3 changed files with 15 additions and 13 deletions

View File

@ -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
}

View File

@ -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<String, Version> myVersions = new ConcurrentHashMap<>();
private List<String> 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);
}
}

View File

@ -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