mirror of https://github.com/apache/lucene.git
SOLR-14266: Fix or suppress 14 resource leak warnings in apache/solr/core
This commit is contained in:
parent
0d20c7b32a
commit
a0e158c3d0
|
@ -206,6 +206,9 @@ Other Changes
|
|||
|
||||
* SOLR-7880: Update commons-cli to 1.4 (Erick Erickson)
|
||||
|
||||
* SOLR-14226Fix or suppress 14 resource leak warnings in apache/solr/core (Andras Salaman via
|
||||
Erick Erickson)
|
||||
|
||||
================== 8.5.1 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -211,7 +211,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4 {
|
|||
loader.close();
|
||||
}
|
||||
|
||||
public void testCacheWrongType() {
|
||||
public void testCacheWrongType() throws Exception {
|
||||
clearCache();
|
||||
|
||||
SolrResourceLoader loader = new SolrResourceLoader();
|
||||
|
@ -226,5 +226,6 @@ public class ResourceLoaderTest extends SolrTestCaseJ4 {
|
|||
// This should work, but won't if earlier call succeeding corrupting the cache
|
||||
TokenizerFactory tf = loader.newInstance(className, TokenizerFactory.class, new String[0], params, new Object[]{new HashMap<>(args)});
|
||||
assertNotNull("Did not load Tokenizer after bad call earlier", tf);
|
||||
loader.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,17 +241,18 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
checkNotInCores(cc, Arrays.asList("collection2", "collection3"));
|
||||
|
||||
// verify that getting metrics from an unloaded core doesn't cause exceptions (SOLR-12541)
|
||||
MetricsHandler handler = new MetricsHandler(h.getCoreContainer());
|
||||
try (MetricsHandler handler = new MetricsHandler(h.getCoreContainer())) {
|
||||
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
handler.handleRequest(makeReq(core1, CommonParams.QT, "/admin/metrics"), resp);
|
||||
NamedList values = resp.getValues();
|
||||
assertNotNull(values.get("metrics"));
|
||||
values = (NamedList) values.get("metrics");
|
||||
NamedList nl = (NamedList) values.get("solr.core.collection2");
|
||||
assertNotNull(nl);
|
||||
Object o = nl.get("REPLICATION./replication.indexPath");
|
||||
assertNotNull(o);
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
handler.handleRequest(makeReq(core1, CommonParams.QT, "/admin/metrics"), resp);
|
||||
NamedList values = resp.getValues();
|
||||
assertNotNull(values.get("metrics"));
|
||||
values = (NamedList) values.get("metrics");
|
||||
NamedList nl = (NamedList) values.get("solr.core.collection2");
|
||||
assertNotNull(nl);
|
||||
Object o = nl.get("REPLICATION./replication.indexPath");
|
||||
assertNotNull(o);
|
||||
}
|
||||
|
||||
|
||||
// Note decrementing the count when the core is removed from the lazyCores list is appropriate, since the
|
||||
|
@ -361,28 +362,29 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
private void createViaAdmin(CoreContainer cc, String name, boolean isTransient,
|
||||
boolean loadOnStartup) throws Exception {
|
||||
|
||||
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
||||
CoreAdminParams.NAME, name,
|
||||
CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
|
||||
CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
|
||||
resp);
|
||||
try (final CoreAdminHandler admin = new CoreAdminHandler(cc)) {
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
||||
CoreAdminParams.NAME, name,
|
||||
CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
|
||||
CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
|
||||
resp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void unloadViaAdmin(CoreContainer cc, String name) throws Exception {
|
||||
|
||||
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.UNLOAD.toString(),
|
||||
CoreAdminParams.CORE, name),
|
||||
resp);
|
||||
|
||||
try (final CoreAdminHandler admin = new CoreAdminHandler(cc)) {
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.UNLOAD.toString(),
|
||||
CoreAdminParams.CORE, name),
|
||||
resp);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that creating a transient core from the admin handler correctly respects the transient limits etc.
|
||||
|
@ -634,12 +636,13 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
// if ok==false, the core being examined should have a failure in the list.
|
||||
private void checkStatus(CoreContainer cc, Boolean ok, String core) throws Exception {
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.STATUS.toString(),
|
||||
CoreAdminParams.CORE, core),
|
||||
resp);
|
||||
try (final CoreAdminHandler admin = new CoreAdminHandler(cc)) {
|
||||
admin.handleRequestBody
|
||||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.STATUS.toString(),
|
||||
CoreAdminParams.CORE, core),
|
||||
resp);
|
||||
}
|
||||
|
||||
Map<String, Exception> failures =
|
||||
(Map<String, Exception>) resp.getValues().get("initFailures");
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.apache.solr.core.backup.repository;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.core.HdfsDirectoryFactory;
|
||||
|
@ -28,68 +30,76 @@ import static org.junit.Assert.assertEquals;
|
|||
public class HdfsBackupRepositoryTest {
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testHdfsHomePropertyMissing() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testHdfsHomePropertyMissing() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHdfsHomePropertySet() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testHdfsHomePropertySet() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = ClassCastException.class)
|
||||
public void testCopyBufferSizeNonNumeric() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", "xyz");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testCopyBufferSizeNonNumeric() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", "xyz");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = ClassCastException.class)
|
||||
public void testCopyBufferSizeWrongType() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", "8192");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testCopyBufferSizeWrongType() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", "8192");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCopyBufferSizeNegative() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", -1);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testCopyBufferSizeNegative() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", -1);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCopyBufferSizeZero() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", 0);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
public void testCopyBufferSizeZero() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add("solr.hdfs.buffer.size", 0);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyBufferSet() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
namedList.add("solr.hdfs.buffer.size", 32768);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
assertEquals(hdfsBackupRepository.copyBufferSize, 32768);
|
||||
public void testCopyBufferSet() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
namedList.add("solr.hdfs.buffer.size", 32768);
|
||||
hdfsBackupRepository.init(namedList);
|
||||
assertEquals(hdfsBackupRepository.copyBufferSize, 32768);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyBufferDefaultSize() {
|
||||
HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository();
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
assertEquals(hdfsBackupRepository.copyBufferSize, HdfsDirectory.DEFAULT_BUFFER_SIZE);
|
||||
public void testCopyBufferDefaultSize() throws IOException {
|
||||
try (HdfsBackupRepository hdfsBackupRepository = new HdfsBackupRepository()) {
|
||||
NamedList<Object> namedList = new SimpleOrderedMap<>();
|
||||
namedList.add(HdfsDirectoryFactory.HDFS_HOME, "hdfs://localhost");
|
||||
hdfsBackupRepository.init(namedList);
|
||||
assertEquals(hdfsBackupRepository.copyBufferSize, HdfsDirectory.DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue