From 0a89ffaf96f63617968c208afcaf9bfb293490ea Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Sat, 19 Mar 2016 14:53:59 +0100 Subject: [PATCH] SOLR-8874: Make Solr tests work with Java 9 Jigsaw --- .../src/java/org/apache/lucene/util/LuceneTestCase.java | 9 ++++++--- solr/common-build.xml | 7 +++++-- .../solr/morphlines/cell/SolrCellMorphlineTest.java | 3 ++- .../morphlines/solr/AbstractSolrMorphlineTestBase.java | 3 +++ .../morphlines/solr/AbstractSolrMorphlineZkTestBase.java | 3 +++ .../org/apache/solr/cloud/SaslZkACLProviderTest.java | 2 ++ .../org/apache/solr/cloud/TestCloudDeleteByQuery.java | 6 ++++-- .../org/apache/solr/core/TestImplicitCoreProperties.java | 4 +++- .../solr/handler/admin/CoreAdminCreateDiscoverTest.java | 1 + .../src/java/org/apache/solr/SolrTestCaseJ4.java | 1 + .../java/org/apache/solr/cloud/SolrCloudTestCase.java | 4 +++- 11 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index e5aa7a2e4ef..5e50e58324e 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -568,11 +568,14 @@ public abstract class LuceneTestCase extends Assert { private final static long STATIC_LEAK_THRESHOLD = 10 * 1024 * 1024; /** By-name list of ignored types like loggers etc. */ - private final static Set STATIC_LEAK_IGNORED_TYPES = - Collections.unmodifiableSet(new HashSet<>(Arrays.asList( + private final static Set STATIC_LEAK_IGNORED_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "org.slf4j.Logger", "org.apache.solr.SolrLogFormatter", - EnumSet.class.getName()))); + "java.io.File", // Solr sometimes refers to this in a static way, but it has a "java.nio.fs.Path" inside + Path.class.getName(), // causes problems because interface is implemented by hidden classes + Class.class.getName(), + EnumSet.class.getName() + ))); /** * This controls how suite-level rules are nested. It is important that _all_ rules declared diff --git a/solr/common-build.xml b/solr/common-build.xml index 78e10aabac1..d2672587edc 100644 --- a/solr/common-build.xml +++ b/solr/common-build.xml @@ -152,10 +152,13 @@ - + + + + diff --git a/solr/contrib/morphlines-cell/src/test/org/apache/solr/morphlines/cell/SolrCellMorphlineTest.java b/solr/contrib/morphlines-cell/src/test/org/apache/solr/morphlines/cell/SolrCellMorphlineTest.java index 6c9487a5360..9a43b423f92 100644 --- a/solr/contrib/morphlines-cell/src/test/org/apache/solr/morphlines/cell/SolrCellMorphlineTest.java +++ b/solr/contrib/morphlines-cell/src/test/org/apache/solr/morphlines/cell/SolrCellMorphlineTest.java @@ -42,7 +42,8 @@ public class SolrCellMorphlineTest extends AbstractSolrMorphlineTestBase { @BeforeClass public static void beforeClass2() { assumeFalse("FIXME: Morphlines currently has issues with Windows paths", Constants.WINDOWS); - assumeFalse("This test fails with Java 9 (https://issues.apache.org/jira/browse/PDFBOX-3155)", Constants.JRE_IS_MINIMUM_JAVA9); + assumeFalse("This test fails with Java 9 (https://issues.apache.org/jira/browse/PDFBOX-3155, https://issues.apache.org/jira/browse/SOLR-8876)", + Constants.JRE_IS_MINIMUM_JAVA9); } @Before diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineTestBase.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineTestBase.java index cf0312870b9..9c79c07d269 100644 --- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineTestBase.java +++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineTestBase.java @@ -21,6 +21,7 @@ import com.google.common.base.Joiner; import com.google.common.io.Files; import com.typesafe.config.Config; import org.apache.commons.io.FileUtils; +import org.apache.lucene.util.Constants; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrQuery; @@ -85,6 +86,8 @@ public class AbstractSolrMorphlineTestBase extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { + assumeFalse("This test fails on Java 9 (https://issues.apache.org/jira/browse/SOLR-8876)", Constants.JRE_IS_MINIMUM_JAVA9); + // TODO: test doesn't work with some Locales, see SOLR-6458 savedLocale = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java index 6c76ecb9d78..4d95a4f9198 100644 --- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java +++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java @@ -25,6 +25,7 @@ import com.codahale.metrics.MetricRegistry; import com.google.common.collect.ListMultimap; import com.typesafe.config.Config; import org.apache.commons.io.FileUtils; +import org.apache.lucene.util.Constants; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.cloud.AbstractFullDistribZkTestBase; import org.apache.solr.cloud.AbstractZkTestCase; @@ -63,6 +64,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri @BeforeClass public static void setupClass() throws Exception { + assumeFalse("This test fails on Java 9 (https://issues.apache.org/jira/browse/SOLR-8876)", Constants.JRE_IS_MINIMUM_JAVA9); + assumeFalse("This test fails on UNIX with Turkish default locale (https://issues.apache.org/jira/browse/SOLR-6387)", new Locale("tr").getLanguage().equals(Locale.getDefault().getLanguage())); solrHomeDirectory = createTempDir().toFile(); diff --git a/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java b/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java index 9d457468147..9381c031971 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java @@ -56,6 +56,8 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() { + assumeFalse("FIXME: This test fails on Java 9 (https://issues.apache.org/jira/browse/SOLR-8052)", Constants.JRE_IS_MINIMUM_JAVA9); + assumeFalse("FIXME: SOLR-7040: This test fails under IBM J9", Constants.JAVA_VENDOR.startsWith("IBM")); System.setProperty("solrcloud.skip.autorecovery", "true"); diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java index f4436eb9e65..27818966c03 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java @@ -19,6 +19,8 @@ package org.apache.solr.cloud; import java.io.File; import java.lang.invoke.MethodHandles; import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -91,10 +93,10 @@ public class TestCloudDeleteByQuery extends SolrCloudTestCase { private static void createMiniSolrCloudCluster() throws Exception { final String configName = "solrCloudCollectionConfig"; - File configDir = new File(TEST_HOME() + File.separator + "collection1" + File.separator + "conf"); + final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf"); configureCluster(NUM_SERVERS) - .addConfig(configName, configDir.toPath()) + .addConfig(configName, configDir) .configure(); Map collectionProperties = new HashMap<>(); diff --git a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java index 149d2870f80..885ad71a715 100644 --- a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java +++ b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java @@ -34,8 +34,10 @@ public class TestImplicitCoreProperties extends SolrTestCaseJ4 { @AfterClass public static void teardownContainer() { - if (cc != null) + if (cc != null) { cc.shutdown(); + } + cc = null; } @Test diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java index cf41dc5a9a3..41807c76726 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java @@ -58,6 +58,7 @@ public class CoreAdminCreateDiscoverTest extends SolrTestCaseJ4 { @AfterClass public static void afterClass() throws Exception { admin = null; // Release it or the test harness complains. + solrHomeDirectory = null; } private static void setupCore(String coreName, boolean blivet) throws IOException { diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index c3ce47de93c..6e511d7e4d6 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -265,6 +265,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase { // clean up static sslConfig = null; + testSolrHome = null; } IpTables.unblockAllPorts(); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java index 615365e585a..386419fb71c 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java @@ -150,8 +150,10 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 { @AfterClass public static void shutdownCluster() throws Exception { - if (cluster != null) + if (cluster != null) { cluster.shutdown(); + } + cluster = null; } @Before