Apache Solr open-source search software
Test framework code review and clean ups (#3920)
Eric Pughf14328f97b06
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.javaindex f9779cfb551..1732cd487d0 100644--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java@@ -207,10 +207,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {int foo_i_counter = 0;for (SolrClient client : clients) {foo_i_counter++;- indexDoc(- client,- params("commit", "true"), // SOLR-4923- sdoc(id, 1, i1, 100, tlong, 100, "foo_i", foo_i_counter));+ indexDoc(client, sdoc(id, 1, i1, 100, tlong, 100, "foo_i", foo_i_counter));// after every update+commit, check all the shards consistencyqueryAndCompareShards(params("q", "id:1", "distrib", "false", "sanity_check", "non_distrib_id_1_lookup"));diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.javaindex 9ce0684fdf0..a5cad568b11 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java@@ -1548,7 +1548,7 @@ public class DistributedFacetPivotLargeTest extends BaseDistributedSearchTestCas* Builds up a SolrInputDocument using the specified fields, then adds it to the specified client* as well as the control client*- * @see #indexDoc(SolrClient, SolrParams, SolrInputDocument)+ * @see #indexDoc(SolrClient, SolrInputDocument)* @see #sdoc*/private void addPivotDoc(SolrClient client, Object... fields)diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.javaindex 27876850858..465c771ee2c 100644--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java@@ -77,20 +77,20 @@ import org.slf4j.LoggerFactory;/*** Helper base class for distributed search test cases*- * <p>By default, for Nightly runs, all tests in sub-classes will execute with 1, 2, ...+ * <p>By default, for Nightly runs, all tests in subclasses will execute with 1, 2, ...* DEFAULT_MAX_SHARD_COUNT number of shards set up repeatedly. For non-nightly tests, they will* execute with 2 shards, to speed up total execution time.*- * <p>In general, it's preferable to annotate the tests in sub-classes with a+ * <p>In general, it's preferable to annotate the tests in subclasses with a* {@literal @}ShardsFixed(num = N) or a {@literal @}ShardsRepeat(min = M, max = N) to indicate* whether the test should be called once, with a fixed number of shards, or called repeatedly for* number of shards = M to N.** <p>In some cases though, if the number of shards has to be fixed, but the number itself is- * dynamic, or if it has to be set as a default for all sub-classes of a sub-class, there's a+ * dynamic, or if it has to be set as a default for all subclasses of a subclass, there's a* fixShardCount(N) available, which is identical to {@literal @}ShardsFixed(num = N) for all tests* without annotations in that class hierarchy. Ideally this function should be retired in favour of- * better annotations..+ * better annotations.** @since solr 1.5*/@@ -123,13 +123,13 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {@SuppressWarnings("deprecation")@BeforeClass// Sets the solr.security.allow.urls.enable=false, disabling the need to provide an allow list.- public static void setSolrEnableUrlUrlAllowList() throws Exception {+ public static void setSolrEnableUrlUrlAllowList() {systemSetPropertyEnableUrlAllowList(false);}@SuppressWarnings("deprecation")@AfterClass- public static void clearSolrEnableUrlUrlAllowList() throws Exception {+ public static void clearSolrEnableUrlUrlAllowList() {systemClearPropertySolrEnableUrlAllowList();}@@ -453,7 +453,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {for (int i = 0; i < fields.length; i += 2) {doc.addField((String) (fields[i]), fields[i + 1]);}- } // add random fields to the documet before indexing+ } // add random fields to the document before indexingprotected void indexr(Object... fields) throws Exception {SolrInputDocument doc = new SolrInputDocument();@@ -480,10 +480,10 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {/** Indexes the document in both the control client, and a randomly selected client */protected void indexDoc(SolrInputDocument doc) throws IOException, SolrServerException {- indexDoc(clientFor(doc), null, doc);+ indexDoc(clientFor(doc), doc);}- protected void indexDoc(SolrClient client, SolrParams params, SolrInputDocument doc)+ protected void indexDoc(SolrClient client, SolrInputDocument doc)throws IOException, SolrServerException {controlClient.add(doc);if (shardCount == 0) { // mostly for temp debugging@@ -675,7 +675,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {public QueryResponse queryAndCompare(SolrParams params, SolrClient... clients)throws SolrServerException, IOException {- return queryAndCompare(params, Arrays.<SolrClient>asList(clients));+ return queryAndCompare(params, Arrays.asList(clients));}public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients)@@ -721,7 +721,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {Object prev = mapB.put(b.getName(i), b.getVal(i));}- return compare(mapA, mapB, flags, handle);+ return compare(mapA, mapB, handle);}int posa = 0, posb = 0;@@ -786,7 +786,6 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {public static String compare1(@SuppressWarnings({"rawtypes"}) Map a,@SuppressWarnings({"rawtypes"}) Map b,- int flags,Map<String, Integer> handle) {String cmp;@@ -808,17 +807,15 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {public static String compare(@SuppressWarnings({"rawtypes"}) Map a,@SuppressWarnings({"rawtypes"}) Map b,- int flags,Map<String, Integer> handle) {String cmp;- cmp = compare1(a, b, flags, handle);+ cmp = compare1(a, b, handle);if (cmp != null) return cmp;- return compare1(b, a, flags, handle);+ return compare1(b, a, handle);}- public static String compare(- SolrDocument a, SolrDocument b, int flags, Map<String, Integer> handle) {- return compare(a.getFieldValuesMap(), b.getFieldValuesMap(), flags, handle);+ public static String compare(SolrDocument a, SolrDocument b, Map<String, Integer> handle) {+ return compare(a.getFieldValuesMap(), b.getFieldValuesMap(), handle);}public static String compare(@@ -851,7 +848,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {// only for completely ordered results (ties might be in a different order)if (ordered) {for (int i = 0; i < a.size(); i++) {- cmp = compare(a.get(i), b.get(i), 0, handle);+ cmp = compare(a.get(i), b.get(i), handle);if (cmp != null) return "[" + i + "]" + cmp;}return null;@@ -872,7 +869,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {}}// if (docb == null) return "[id="+key+"]";- cmp = compare(doc, docb, 0, handle);+ cmp = compare(doc, docb, handle);if (cmp != null) return "[id=" + key + "]" + cmp;}return null;@@ -902,11 +899,11 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {}if (a instanceof SolrDocument && b instanceof SolrDocument) {- return compare((SolrDocument) a, (SolrDocument) b, flags, handle);+ return compare((SolrDocument) a, (SolrDocument) b, handle);}if (a instanceof Map && b instanceof Map) {- return compare((Map) a, (Map) b, flags, handle);+ return compare((Map) a, (Map) b, handle);}if (a instanceof Object[] && b instanceof Object[]) {@@ -1192,7 +1189,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {* @see #CORE_PROPERTIES_FILENAME*/private void seedCoreRootDirWithDefaultTestCore(Path coreRootDirectory) throws IOException {- // Kludgy and brittle with assumptions about writeCoreProperties, but i don't want to+ // Kludgy and brittle with assumptions about writeCoreProperties, but I don't want to// try to change the semantics of that method to ignore existing filesPath coreDir = coreRootDirectory.resolve(DEFAULT_TEST_CORENAME);if (Files.notExists(coreDir.resolve(CORE_PROPERTIES_FILENAME))) {diff --git a/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java b/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.javaindex b6b95ef6d7f..08df42a6c8f 100644--- a/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java+++ b/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java@@ -187,7 +187,7 @@ class CollectionTester {sb.append(seg);sb.append(']');} else {- sb.append(seg.toString());+ sb.append(seg);}}return sb.toString();diff --git a/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java b/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.javaindex 4c65603d9c5..298b89d38da 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java@@ -33,7 +33,7 @@ public class SolrIgnoredThreadsFilter implements ThreadFilter {String threadName = t.getName();- // due to netty - will stop on it's own+ // due to netty - will stop on its ownif (threadName.startsWith("globalEventExecutor")) {return true;}@@ -43,7 +43,7 @@ public class SolrIgnoredThreadsFilter implements ThreadFilter {return true;}- // These is a java pool for the collection stream api+ // This is a java pool for the collection stream apiif (threadName.startsWith("ForkJoinPool.")) {return true;}diff --git a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.javaindex 69b9606f4eb..93e5424c824 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java@@ -114,7 +114,7 @@ public abstract class SolrJettyTestBase extends SolrTestCaseJ4 {}/**- * Create a new solr client. If createJetty was called, a http implementation will be created,+ * Create a new solr client. If createJetty was called, an http implementation will be created,* otherwise an embedded implementation will be created. Subclasses should override for other* options.*/diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.javaindex 4493be05eb0..a29e3d0da43 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java@@ -81,9 +81,6 @@ public class SolrTestCase extends LuceneTestCase {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());- private static final Pattern NAMING_CONVENTION_TEST_SUFFIX =- Pattern.compile("(.+\\.)([^.]+)(Test)");-private static final Pattern NAMING_CONVENTION_TEST_PREFIX =Pattern.compile("(.+\\.)(Test)([^.]+)");@@ -151,7 +148,7 @@ public class SolrTestCase extends LuceneTestCase {ExternalPaths.DEFAULT_CONFIGSET);}- // set solr.install.dir needed by some test configs outside of the test sandbox (!)+ // set solr.install.dir needed by some test configs outside the test sandbox (!)if (ExternalPaths.SOURCE_HOME != null) {System.setProperty("solr.install.dir", ExternalPaths.SOURCE_HOME.toString());}@@ -167,7 +164,7 @@ public class SolrTestCase extends LuceneTestCase {/*** Special hook for sanity checking if any tests trigger failures when an Assumption failure- * occures in a {@link BeforeClass} method+ * occurs in a {@link BeforeClass} method** @lucene.internal*/diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex 09691e4222f..b216fd980e6 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -27,7 +27,6 @@ import com.carrotsearch.randomizedtesting.RandomizedTest;import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;import java.io.IOException;import java.io.OutputStreamWriter;-import java.io.Reader;import java.io.StringReader;import java.io.StringWriter;import java.io.UncheckedIOException;@@ -229,7 +228,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {/*** Annotation for test classes that want to disable PointFields. PointFields will otherwise- * randomly used by some schemas.+ * randomly be used by some schemas.*/@Documented@Inherited@@ -375,7 +374,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {"SOLR-11606: ByteBuddy used by Mockito is not working with this JVM version.",e.getTargetException());} catch (ReflectiveOperationException e) {- fail("ByteBuddy and Mockito are not available on classpath: " + e.toString());+ fail("ByteBuddy and Mockito are not available on classpath: " + e);}}@@ -403,7 +402,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {changedFactory = true;}- public static void resetFactory() throws Exception {+ public static void resetFactory() {if (!changedFactory) return;changedFactory = false;if (savedFactory != null) {@@ -425,7 +424,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {// TestMiniSolrCloudClusterSSL.testSslAndClientAuth as well.sslRandomizer =new SSLRandomizer(- sslRandomizer.ssl, 0.0D, (sslRandomizer.debug + " w/ MAC_OS_X supressed clientAuth"));+ sslRandomizer.ssl,+ 0.0D,+ (sslRandomizer.debug + " w/ MAC_OS_X suppressed clientAuth"));}SSLTestConfig result = sslRandomizer.createSSLTestConfig();@@ -443,13 +444,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {return (isSSLMode() ? "https" : "http") + "://127.0.0.1:" + port + "/solr";}- protected static MockTokenizer whitespaceMockTokenizer(Reader input) throws IOException {- MockTokenizer mockTokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, false);- mockTokenizer.setReader(input);- return mockTokenizer;- }-- protected static MockTokenizer whitespaceMockTokenizer(String input) throws IOException {+ protected static MockTokenizer whitespaceMockTokenizer(String input) {MockTokenizer mockTokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, false);mockTokenizer.setReader(new StringReader(input));return mockTokenizer;@@ -528,9 +523,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {* re-initialize a new value. All directories returned by any calls to this method will* automatically be cleaned up per {@link #createTempDir}*- * <p>NOTE: calling this method is not requried, it will be implicitly called as needed when+ * <p>NOTE: calling this method is not required, it will be implicitly called as needed when* initializing cores. Callers that don't care about using {@link #initCore} and just want a- * temporary directory to put data in sould instead be using {@link #createTempDir} directly.+ * temporary directory to put data in should instead be using {@link #createTempDir} directly.** @see #initCoreDataDir*/@@ -551,7 +546,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {* Counter for ensuring we don't ask {@link #createTempDir} to try and re-create the same dir* prefix over and over.*- * <p>(createTempDir has it's own counter for uniqueness, but it tries all numbers in a loop until+ * <p>(createTempDir has its own counter for uniqueness, but it tries all numbers in a loop until* it finds one available. No reason to force that O(N^2) behavior when we know we've already* created N previous directories with the same prefix.)*/@@ -651,10 +646,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {return getTestClass().getName();}- protected static String getSimpleClassName() {- return getTestClass().getSimpleName();- }-protected static String configString;protected static String schemaString;protected static Path testSolrHome;@@ -709,8 +700,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {* <li>initializes the LocalRequestFactory lrf using sensible defaults.* </ul>*/- private static String factoryProp;-public static void initCore() throws Exception {log.info("####initCore");@@ -830,12 +819,10 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {h.close();}- if (factoryProp == null) {- System.clearProperty("solr.directoryFactory");- }+ System.clearProperty("solr.directoryFactory");if (System.getProperty(UPDATELOG_SYSPROP) != null) {- // clears the updatelog sysprop at the end of the test run+ // clears the updatelog system property at the end of the test runSystem.clearProperty(UPDATELOG_SYSPROP);}@@ -1002,7 +989,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}for (String test : tests) {- if (test == null || test.length() == 0) continue;+ if (test == null || test.isEmpty()) continue;String testJSON = json(test);try {@@ -1197,7 +1184,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {Map<String, String[]> params = new HashMap<>();MultiMapSolrParams mmparams = new MultiMapSolrParams(params);params.put(UpdateParams.UPDATE_CHAIN, new String[] {updateRequestProcessorChain});- SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) {};+ SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams) {};UpdateRequestHandler handler = new UpdateRequestHandler();handler.init(null);@@ -1209,7 +1196,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}/**- * Generates an <add><doc>... XML String with options on the add.+ * Generates a <add><doc>... XML String with options on the add.** @param doc the Document to add* @param args 0th and Even numbered args are param names, Odds are param values.@@ -1338,10 +1325,10 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {/*** Does a low level delete of all docs in the index.*- * <p>The behavior of this method is slightly different then doing a normal <code>*:*</code> DBQ+ * <p>The behavior of this method is slightly different from doing a normal <code>*:*</code> DBQ* because it takes advantage of internal methods to ensure all index data is wiped, regardless of* optimistic concurrency version constraints -- making it suitable for tests that create- * synthetic versions, and/or require a completely pristine index w/o any field metdata.+ * synthetic versions, and/or require a completely pristine index w/o any field metadata.** @see #deleteByQueryAndGetVersion*/@@ -1418,7 +1405,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {/*** Converts "test JSON" strings into JSON parseable by our JSON parser. For example, this method- * changed single quoted strings into double quoted strings before the parser could natively+ * changed single quoted strings into double-quoted strings before the parser could natively* handle them.** <p>This transformation is automatically applied to JSON test strings (like assertJQ).@@ -1826,10 +1813,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {public IVals numValues;public Vals vals;- public FldType(String fname, Vals vals) {- this(fname, ZERO_ONE, vals);- }-public FldType(String fname, IVals numValues, Vals vals) {this.fname = fname;this.numValues = numValues;@@ -2160,7 +2143,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}throw new RuntimeException("Cannot find resource in classpath or in file-system (relative to CWD): "- + Path.of(name).toAbsolutePath());+ + file.toAbsolutePath());}public static Path TEST_HOME() {@@ -2678,7 +2661,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}/**- * We want "realistic" unicode strings beyond simple ascii, but because our updates use XML we+ * We want "realistic" Unicode strings beyond simple ascii, but because our updates use XML we* need to ensure we don't get "special" code block.*/public static String randomXmlUsableUnicodeString() {@@ -2721,7 +2704,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}@BeforeClass- public static void assertNonBlockingRandomGeneratorAvailable() throws InterruptedException {+ public static void assertNonBlockingRandomGeneratorAvailable() {final String EGD = "java.security.egd";final String URANDOM = "file:/dev/./urandom";final String ALLOWED = "test.solr.allowed.securerandom";@@ -2854,7 +2837,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {final boolean useDV = random().nextBoolean();System.setProperty(NUMERIC_DOCVALUES_SYSPROP, "" + useDV);- // consume a consistent amount of random data even if sysprop/annotation is set+ // consume a consistent amount of random data even if system property/annotation is setfinal boolean randUsePoints = 0 != random().nextInt(5); // 80% likelihoodfinal String usePointsStr = System.getProperty(USE_NUMERIC_POINTS_SYSPROP);@@ -2904,7 +2887,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {}/**- * Cleans up the randomized sysproperties and variables set by {@link+ * Cleans up the randomized system properties and variables set by {@link* #randomizeNumericTypesProperties}** @see #randomizeNumericTypesPropertiesdiff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.javaindex 5a24a1f2f4d..67922db5a42 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java@@ -131,11 +131,10 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcprivate static final String ZOOKEEPER_FORCE_SYNC = "zookeeper.forceSync";protected static final String DEFAULT_COLLECTION = "collection1";protected volatile ZkTestServer zkServer;- private final AtomicInteger homeCount = new AtomicInteger();@BeforeClasspublic static void beforeThisClass() throws Exception {- // Only For Manual Testing: this will force an fs based dir factory+ // Only For Manual Testing: this will force a fs based dir factory// useFactory(null);}@@ -217,10 +216,6 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcpublic CloudSolrServerClient() {}- public CloudSolrServerClient(SolrClient client) {- this.solrClient = client;- }-public SolrClient getSolrClient() {return solrClient;}@@ -321,10 +316,10 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc}}}- if (useTlogReplicas()) {- log.info("Will use {} replicas unless explicitly asked otherwise", Replica.Type.TLOG);- } else {- log.info("Will use {} replicas unless explicitly asked otherwise", Replica.Type.NRT);+ if (log.isInfoEnabled()) {+ log.info(+ "Will use {} replicas unless explicitly asked otherwise",+ useTlogReplicas() ? Replica.Type.TLOG : Replica.Type.NRT);}}@@ -366,7 +361,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcreturn dataDir;}- protected void initCloud() throws Exception {+ protected void initCloud() {assert (cloudInit == false);cloudInit = true;cloudClient = createCloudClient(DEFAULT_COLLECTION);@@ -554,7 +549,6 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc}});- addedReplicas++;} else {if (log.isInfoEnabled()) {log.info(@@ -592,9 +586,8 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcthrow new RuntimeException(e);}});-- addedReplicas++;}+ addedReplicas++;} else {log.info("create jetty {} in directory {} of type {} for shard{}",@@ -715,7 +708,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcprotected void waitForActiveReplicaCount(CloudSolrClient client, String collection, int expectedNumReplicas)- throws TimeoutException, NotInClusterStateException {+ throws NotInClusterStateException {log.info("Waiting to see {} active replicas in collection: {}", expectedNumReplicas, collection);AtomicInteger nReplicas = new AtomicInteger();@@ -764,7 +757,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc* status.** @deprecated This method is virtually useless as it does not consider the status of either the- * shard or replica, nor wether the node hosting each replica is alive.+ * shard or replica, nor whether the node hosting each replica is alive.*/@Deprecatedprotected int getTotalReplicas(DocCollection c, String collection) {@@ -1095,7 +1088,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcthrows Exception {UpdateRequest up = new UpdateRequest();up.add(batch);- NamedList resp = null;+ NamedList resp;int numRetries = 0;while (true) {try {@@ -1111,7 +1104,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcwaitBeforeRetry);Thread.sleep(waitBeforeRetry * 1000L);} else {- log.error("No more retries available! Add batch failed due to: {}", rootCause);+ log.error("No more retries available! Add batch failed", rootCause);throw exc;}}@@ -1267,7 +1260,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcSlice slice = entry.getValue();if (slice.getState()== Slice.State- .CONSTRUCTION) { // similar to replica recovering; pretend its the same+ .CONSTRUCTION) { // similar to replica recovering; pretend it's the same// thingif (verbose) System.out.println("Found a slice in construction state; will wait.");sawLiveRecovering = true;@@ -1292,7 +1285,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc}}if (!sawLiveRecovering) {- if (verbose) System.out.println("no one is recoverying");+ if (verbose) System.out.println("no one is recovering");return true;} else {return false;@@ -1352,7 +1345,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcreturn false;});} catch (TimeoutException e) {- // If we failed to get a new leader, print some diagnotics before the test fails+ // If we failed to get a new leader, print some diagnostics before the test failsDiagnostics.logThreadDumps("Could not find new leader in specified timeout");zkStateReader.getZkClient().printLayoutToStream(System.out);fail("Could not find new leader even after waiting for 15s");@@ -2034,7 +2027,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearclong controlCount = controlClient.query(new SolrQuery("*:*")).getResults().getNumFound();// do some really inefficient mapping...- Map<String, Slice> slices = null;+ Map<String, Slice> slices;ClusterState clusterState;try (ZkStateReader zk =new ZkStateReader(@@ -2270,7 +2263,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcConfigSetUploadTool tool = new ConfigSetUploadTool(runtime);int res = tool.runTool(SolrCLI.processCommandLineArgs(tool, args));- assertEquals("Tool should have returned 0 for success, returned: " + res, res, 0);+ assertEquals("Tool should have returned 0 for success, returned: " + res, 0, res);}@Override@@ -2353,15 +2346,15 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcZkStateReader.REPLICATION_FACTOR);}if (numNrtReplicas == null) {- numNrtReplicas = Integer.valueOf(0);+ numNrtReplicas = 0;}Integer numTlogReplicas = (Integer) collectionProps.get(ZkStateReader.TLOG_REPLICAS);if (numTlogReplicas == null) {- numTlogReplicas = Integer.valueOf(0);+ numTlogReplicas = 0;}Integer numPullReplicas = (Integer) collectionProps.get(ZkStateReader.PULL_REPLICAS);if (numPullReplicas == null) {- numPullReplicas = Integer.valueOf(0);+ numPullReplicas = 0;}if (confSetName != null) {params.set("collection.configName", confSetName);@@ -3023,18 +3016,6 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc}}- protected void waitForAllWarmingSearchers() throws InterruptedException {- log.info("waitForAllWarmingSearchers");- for (JettySolrRunner jetty : jettys) {- if (!jetty.isRunning()) {- continue;- }- for (SolrCore core : jetty.getCoreContainer().getCores()) {- waitForWarming(core);- }- }- }-protected long getIndexVersion(Replica replica) throws IOException {try (SolrClient client =new HttpSolrClient.Builder(replica.getBaseUrl())@@ -3124,7 +3105,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc} catch (InterruptedException e) {Thread.currentThread().interrupt();throw new RuntimeException(- "Interrupted whie waiting for request completion. Last state seen: " + state, e);+ "Interrupted while waiting for request completion. Last state seen: " + state, e);}}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.javaindex 653e9f3773c..2c423d3f973 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java@@ -49,7 +49,7 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {protected static volatile Path zkDir;@BeforeClass- public static void azt_beforeClass() throws Exception {+ public static void aztBeforeClass() throws Exception {zkDir = createTempDir("zkData");zkServer = new ZkTestServer(zkDir);zkServer.run();@@ -65,7 +65,7 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {}@AfterClass- public static void azt_afterClass() throws Exception {+ public static void aztAfterClass() throws Exception {try {deleteCore();diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.javaindex 7aba886eeb6..5d0a6c5e260 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java@@ -77,7 +77,7 @@ public class ChaosMonkey {// NOTE: CONN_LOSS and EXP are currently being set to "false" intentionally here. Remove the// default value once we know tests pass reliably under those conditionsprivate static final String CONN_LOSS =- System.getProperty("solr.tests.cloud.cm.connloss", "false");+ System.getProperty("solr.tests.cloud.cm.connloss.enabled", "false");private static final String EXP = System.getProperty("solr.tests.cloud.cm.exp", "false");private ZkTestServer zkServer;@@ -101,7 +101,7 @@ public class ChaosMonkey {/*** Our own Random, seeded from LuceneTestCase on init, so that we can produce a consistent- * sequence of random chaos regardless of if/how othe threads access the test randomness in other+ * sequence of random chaos regardless of if/how the threads access the test randomness in other* threads** @see LuceneTestCase#random()@@ -248,13 +248,6 @@ public class ChaosMonkey {}}- public void stopShard(String slice) throws Exception {- List<CloudJettyRunner> jetties = shardToJetty.get(slice);- for (CloudJettyRunner jetty : jetties) {- stopJetty(jetty);- }- }-public void stopShardExcept(String slice, String shardName) throws Exception {List<CloudJettyRunner> jetties = shardToJetty.get(slice);for (CloudJettyRunner jetty : jetties) {@@ -360,7 +353,7 @@ public class ChaosMonkey {}int chance = chaosRandom.nextInt(10);- CloudJettyRunner cjetty = null;+ CloudJettyRunner cjetty;if (chance <= 5 && aggressivelyKillLeaders && canKillIndexer) {// if killLeader, really aggressively go after leaderscjetty = shardToLeaderJetty.get(slice);@@ -381,7 +374,7 @@ public class ChaosMonkey {}}- ZkNodeProps leader = null;+ ZkNodeProps leader;try {leader = zkStateReader.getLeaderRetry(collection, slice);} catch (Throwable t) {diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java b/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.javaindex fbf5c52ddf2..e529a2e3f4a 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java@@ -165,9 +165,9 @@ public class CloudInspectUtil {sb.append(" numFound=").append(lst.getNumFound());}sb.append("]=");- sb.append(lst.subList(0, maxSz / 2).toString());+ sb.append(lst.subList(0, maxSz / 2));sb.append(" , [...] , ");- sb.append(lst.subList(lst.size() - maxSz / 2, lst.size()).toString());+ sb.append(lst.subList(lst.size() - maxSz / 2, lst.size()));return sb.toString();}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.javaindex dab85c10a8d..8ca5646f03e 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java@@ -55,7 +55,7 @@ class FullThrottleStoppableIndexingThread extends StoppableIndexingThread {boolean doDeletes,int clientSoTimeout) {super(controlClient, cloudClient, id, doDeletes);- setName("FullThrottleStopableIndexingThread");+ setName("FullThrottleStoppableIndexingThread");setDaemon(true);this.clients = clients;this.httpClient = httpClient;diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/IpTables.java b/solr/test-framework/src/java/org/apache/solr/cloud/IpTables.javaindex 901813ae913..4011e4f74db 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/IpTables.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/IpTables.java@@ -33,15 +33,6 @@ public class IpTables {private static final Set<Integer> BLOCK_PORTS =Collections.synchronizedSet(new HashSet<Integer>());- public static void blockPort(int port) throws IOException, InterruptedException {- if (ENABLED) {- log.info("Block port with iptables: {}", port);- BLOCK_PORTS.add(port);- runCmd(("iptables -A INPUT -p tcp --dport " + port + " -j DROP").split("\\s"));- runCmd(("iptables -A OUTPUT -p tcp --dport " + port + " -j DROP").split("\\s"));- }- }-public static void unblockPort(int port) throws IOException, InterruptedException {if (ENABLED && BLOCK_PORTS.contains(port)) {log.info("Unblock port with iptables: {}", port);diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.javaindex a632928d361..aca47b08e53 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java@@ -152,7 +152,7 @@ public class MiniSolrCloudCluster {+ "</solr>\n";private final Object startupWait = new Object();- private volatile ZkTestServer zkServer; // non-final due to injectChaos()+ private volatile ZkTestServer zkServer;private final boolean externalZkServer;private final List<JettySolrRunner> jettys = new CopyOnWriteArrayList<>();private final Path baseDir;@@ -214,7 +214,7 @@ public class MiniSolrCloudCluster {/*** Create a MiniSolrCloudCluster. Note - this constructor visibility is changed to package- * protected so as to discourage its usage. Ideally *new* functionality should use {@linkplain+ * protected to discourage its usage. Ideally *new* functionality should use {@linkplain* SolrCloudTestCase} to configure any additional parameters.** @param numServers number of Solr servers to start@@ -247,7 +247,7 @@ public class MiniSolrCloudCluster {/*** Create a MiniSolrCloudCluster. Note - this constructor visibility is changed to package- * protected so as to discourage its usage. Ideally *new* functionality should use {@linkplain+ * protected to discourage its usage. Ideally *new* functionality should use {@linkplain* SolrCloudTestCase} to configure any additional parameters.** @param numServers number of Solr servers to start@@ -542,7 +542,7 @@ public class MiniSolrCloudCluster {* Stop a Solr instance** @param index the index of node in collection returned by {@link #getJettySolrRunners()}- * @return the shut down node+ * @return the now shut down node*/public JettySolrRunner stopJettySolrRunner(int index) throws Exception {JettySolrRunner jetty = jettys.get(index);@@ -592,7 +592,7 @@ public class MiniSolrCloudCluster {}});- reader.createClusterStateWatchersAndUpdate(); // up to date aliases & collections+ reader.createClusterStateWatchersAndUpdate(); // up-to-date aliases & collectionsreader.aliasesManager.applyModificationAndExportToZk(aliases -> Aliases.EMPTY);for (String collection : reader.getClusterState().getCollectionNames()) {CollectionAdminRequest.deleteCollection(collection).process(solrClient);@@ -800,32 +800,6 @@ public class MiniSolrCloudCluster {ChaosMonkey.expireSession(jetty, zkServer);}- // Currently not used ;-(- public synchronized void injectChaos(Random random) throws Exception {-- // sometimes we restart one of the jetty nodes- if (random.nextBoolean()) {- JettySolrRunner jetty = jettys.get(random.nextInt(jettys.size()));- jetty.stop();- log.info("============ Restarting jetty");- jetty.start();- }-- // sometimes we restart zookeeper- if (random.nextBoolean()) {- zkServer.shutdown();- log.info("============ Restarting zookeeper");- zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());- zkServer.run(false);- }-- // sometimes we cause a connection loss - sometimes it will hit the overseer- if (random.nextBoolean()) {- JettySolrRunner jetty = jettys.get(random.nextInt(jettys.size()));- ChaosMonkey.causeConnectionLoss(jetty);- }- }-public Overseer getOpenOverseer() {List<Overseer> overseers = new ArrayList<>();for (int i = 0; i < jettys.size(); i++) {@@ -996,13 +970,6 @@ public class MiniSolrCloudCluster {metrics.setHandler(chain);return metrics;}-- /**- * @return optional subj. It may be null, if it's not yet created.- */- public MetricRegistry getMetricRegistry() {- return metricRegistry;- }}private static class Config {diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MockZkStateReader.java b/solr/test-framework/src/java/org/apache/solr/cloud/MockZkStateReader.javaindex 7375d3212f2..8be6099c5e8 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/MockZkStateReader.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MockZkStateReader.java@@ -39,7 +39,7 @@ public class MockZkStateReader extends ZkStateReader {@Overridepublic void registerDocCollectionWatcher(String collection, DocCollectionWatcher stateWatcher) {// the doc collection will never be changed by this mock- // so we just call onStateChanged once with the existing DocCollection object an return+ // so we just call onStateChanged once with the existing DocCollection object and returnstateWatcher.onStateChanged(clusterState.getCollectionOrNull(collection));}}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MultiSolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/MultiSolrCloudTestCase.javaindex a621c04fbbb..0ef706b4e0a 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/MultiSolrCloudTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MultiSolrCloudTestCase.java@@ -85,8 +85,7 @@ public abstract class MultiSolrCloudTestCase extends SolrTestCaseJ4 {protected static void doSetupClusters(final String[] clusterIds,final Function<String, MiniSolrCloudCluster> createFunc,- final BiConsumer<String, MiniSolrCloudCluster> initFunc)- throws Exception {+ final BiConsumer<String, MiniSolrCloudCluster> initFunc) {for (final String clusterId : clusterIds) {assertFalse("duplicate clusterId " + clusterId, clusterId2cluster.containsKey(clusterId));diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.javaindex b5d9e805922..5f1081e05fb 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java@@ -78,9 +78,6 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {@SuppressWarnings({"rawtypes"})public static final Predicate NOT_NULL_PREDICATE = o -> o != null;- private static final List<String> AUDIT_METRICS_KEYS = Arrays.asList("count");- private static final List<String> AUDIT_METRICS_TO_COMPARE = Arrays.asList("count");-@BeforeClasspublic static void enableMetrics() {System.setProperty("metricsEnabled", "true");@@ -98,8 +95,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {int passThrough,int failWrongCredentials,int failMissingCredentials,- int errors)- throws InterruptedException {+ int errors) {String handler = "/authentication/pki";String registryName = "solr.node";Labels labels =@@ -137,8 +133,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {int passThrough,int failWrongCredentials,int failMissingCredentials,- int errors)- throws InterruptedException {+ int errors) {String handler = "/authentication";String registryName = "solr.node";Labels labels =@@ -371,8 +366,8 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {** <p>This can be useful in a {@link TimeOut#waitFor} loop to monitor a cluster and "wait for" A* change in security settings to affect all nodes by comparing the objects in the current Map- * with the one in use prior to executing some test command. (providing a work around for the- * security user experienence limitations identified in <a+ * with the one in use prior to executing some test command. (providing a workaround for the+ * security user experience limitations identified in <a* href="https://issues.apache.org/jira/browse/SOLR-13464">SOLR-13464</a> )** @param url A REST url (or any arbitrary String) ending in <code>"authentication"</code> ordiff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.javaindex b2499fc7e2a..7f589e48b23 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@@ -115,7 +115,8 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {* @param nodeCount the number of nodes*/protected static MiniSolrCloudCluster.Builder configureCluster(int nodeCount) {- // By default the MiniSolrCloudCluster being built will randomly (seed based) decide which+ // Default behavior is the MiniSolrCloudCluster being built will randomly (seed based) decide+ // which// collection API strategy to use (distributed or Overseer based) and whether to use PRSconfigurePrsDefault();@@ -370,9 +371,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {protected static Slice getRandomShard(DocCollection collection) {List<Slice> shards = new ArrayList<>(collection.getActiveSlices());if (shards.size() == 0)- fail(- "Couldn't get random shard for collection as it has no shards!\n"- + collection.toString());+ fail("Couldn't get random shard for collection as it has no shards!\n" + collection);Collections.shuffle(shards, random());return shards.get(0);}@@ -381,7 +380,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {protected static Replica getRandomReplica(Slice slice) {List<Replica> replicas = new ArrayList<>(slice.getReplicas());if (replicas.size() == 0)- fail("Couldn't get random replica from shard as it has no replicas!\n" + slice.toString());+ fail("Couldn't get random replica from shard as it has no replicas!\n" + slice);Collections.shuffle(replicas, random());return replicas.get(0);}@@ -390,12 +389,12 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {protected static Replica getRandomReplica(Slice slice, Predicate<Replica> matchPredicate) {List<Replica> replicas = new ArrayList<>(slice.getReplicas());if (replicas.size() == 0)- fail("Couldn't get random replica from shard as it has no replicas!\n" + slice.toString());+ fail("Couldn't get random replica from shard as it has no replicas!\n" + slice);Collections.shuffle(replicas, random());for (Replica replica : replicas) {if (matchPredicate.test(replica)) return replica;}- fail("Couldn't get random replica that matched conditions\n" + slice.toString());+ fail("Couldn't get random replica that matched conditions\n" + slice);return null; // just to keep the compiler happy - fail will always throw an Exception}@@ -476,7 +475,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {for (Replica replica : slice.getReplicas()) {String coreUrl = replica.getCoreUrl();// It seems replica reports its core URL with a trailing slash while shard- // info returned from the query doesn't. Oh well. We will include both, just in case+ // info returned from the query doesn't. Oh, well. We will include both, just in casereplicaTypeMap.put(coreUrl, replica.getType().toString());if (coreUrl.endsWith("/")) {replicaTypeMap.put(diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.javaindex 355f6e38c2f..5ed3b89337b 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java@@ -192,12 +192,4 @@ public class StoppableIndexingThread extends AbstractFullDistribZkTestBase.Stoppureq.add(docs);ureq.process(cloudClient);}-- public int getNumDeletes() {- return numDeletes;- }-- public int getNumAdds() {- return numAdds;- }}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.javaindex b18f255e8bf..1b501e52995 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java@@ -19,17 +19,11 @@ package org.apache.solr.cloud;import static org.apache.solr.cloud.SolrZkServer.ZK_WHITELIST_PROPERTY;import static org.junit.Assert.assertTrue;-import java.io.BufferedReader;import java.io.IOException;-import java.io.InputStreamReader;-import java.io.OutputStream;import java.lang.invoke.MethodHandles;import java.net.InetSocketAddress;-import java.net.Socket;-import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.util.ArrayList;import java.util.Arrays;import java.util.Comparator;import java.util.HashMap;@@ -39,7 +33,6 @@ import java.util.concurrent.ConcurrentHashMap;import java.util.concurrent.TimeUnit;import java.util.concurrent.atomic.AtomicLong;import java.util.concurrent.atomic.AtomicReference;-import javax.management.JMException;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.cloud.SolrZkClient;import org.apache.solr.common.cloud.ZkNodeProps;@@ -48,11 +41,9 @@ import org.apache.solr.common.util.ObjectReleaseTracker;import org.apache.solr.common.util.Utils;import org.apache.zookeeper.CreateMode;import org.apache.zookeeper.KeeperException;-import org.apache.zookeeper.WatchedEvent;import org.apache.zookeeper.Watcher;import org.apache.zookeeper.ZooDefs;import org.apache.zookeeper.data.Stat;-import org.apache.zookeeper.jmx.ManagedUtil;import org.apache.zookeeper.server.NIOServerCnxnFactory;import org.apache.zookeeper.server.Request;import org.apache.zookeeper.server.ServerCnxn;@@ -62,7 +53,6 @@ import org.apache.zookeeper.server.ZKDatabase;import org.apache.zookeeper.server.ZooKeeperServer;import org.apache.zookeeper.server.command.FourLetterCommands;import org.apache.zookeeper.server.persistence.FileTxnSnapLog;-import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;import org.apache.zookeeper.test.ClientBase;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -118,23 +108,6 @@ public class ZkTestServer {private volatile LimitViolationAction violationReportAction = LimitViolationAction.REPORT;private volatile WatchLimiter limiter = new WatchLimiter(1, LimitViolationAction.IGNORE);- protected void initializeAndRun(String[] args) throws ConfigException, IOException {- try {- ManagedUtil.registerLog4jMBeans();- } catch (JMException e) {- log.warn("Unable to register log4j JMX control", e);- }-- ServerConfig config = new ServerConfig();- if (args.length == 1) {- config.parse(args[0]);- } else {- config.parse(args);- }-- runFromConfig(config);- }-private class WatchLimit {private long limit;private final String desc;@@ -182,13 +155,6 @@ public class ZkTestServer {}}- public void updateForFire(WatchedEvent event) {- if (log.isDebugEnabled()) {- log.debug("Watch fired: {}: {}", desc, event.getPath());- }- counters.get(event.getPath()).decrementAndGet();- }-private String reportLimitViolations() {String[] maxKeys = maxCounters.keySet().toArray(new String[0]);Arrays.sort(@@ -245,29 +211,6 @@ public class ZkTestServer {+ dataLimit.reportLimitViolations()+ childrenLimit.reportLimitViolations();}-- private void updateForFire(WatchedEvent event) {- switch (event.getType()) {- case None:- break;- case NodeCreated:- case NodeDeleted:- statLimit.updateForFire(event);- break;- case NodeDataChanged:- dataLimit.updateForFire(event);- break;- case NodeChildrenChanged:- childrenLimit.updateForFire(event);- break;- case ChildWatchRemoved:- break;- case DataWatchRemoved:- break;- case PersistentWatchRemoved:- break;- }- }}private static class TestZKDatabase extends ZKDatabase {@@ -658,72 +601,6 @@ public class ZkTestServer {ObjectReleaseTracker.release(this);}- public static class HostPort {- String host;- int port;-- HostPort(String host, int port) {- assert !host.contains(":") : host;- this.host = host;- this.port = port;- }- }-- /**- * Send the 4letterword- *- * @param host the destination host- * @param port the destination port- * @param cmd the 4letterword- * @return server response- */- public static String send4LetterWord(String host, int port, String cmd) throws IOException {- log.info("connecting to {} {}", host, port);- BufferedReader reader = null;- try (Socket sock = new Socket(host, port)) {- OutputStream outstream = sock.getOutputStream();- outstream.write(cmd.getBytes(StandardCharsets.US_ASCII));- outstream.flush();- // this replicates NC - close the output stream before reading- sock.shutdownOutput();-- reader =- new BufferedReader(- new InputStreamReader(sock.getInputStream(), StandardCharsets.US_ASCII));- StringBuilder sb = new StringBuilder();- String line;- while ((line = reader.readLine()) != null) {- sb.append(line).append("\n");- }- return sb.toString();- } finally {- if (reader != null) {- reader.close();- }- }- }-- public static List<HostPort> parseHostPortList(String hplist) {- log.info("parse host and port list: {}", hplist);- ArrayList<HostPort> alist = new ArrayList<>();- for (String hp : hplist.split(",")) {- int idx = hp.lastIndexOf(':');- String host = hp.substring(0, idx);- int port;- try {- port = Integer.parseInt(hp.substring(idx + 1));- } catch (RuntimeException e) {- throw new RuntimeException("Problem parsing " + hp + e.toString());- }- alist.add(new HostPort(host, port));- }- return alist;- }-- public int getTheTickTime() {- return theTickTime;- }-public void setTheTickTime(int theTickTime) {this.theTickTime = theTickTime;}@@ -740,22 +617,6 @@ public class ZkTestServer {return zkServer.getLimiter();}- public int getMaxSessionTimeout() {- return maxSessionTimeout;- }-- public int getMinSessionTimeout() {- return minSessionTimeout;- }-- public void setMaxSessionTimeout(int maxSessionTimeout) {- this.maxSessionTimeout = maxSessionTimeout;- }-- public void setMinSessionTimeout(int minSessionTimeout) {- this.minSessionTimeout = minSessionTimeout;- }-void buildZooKeeper(String config, String schema) throws Exception {buildZooKeeper(SOLRHOME, config, schema);}@@ -854,6 +715,7 @@ public class ZkTestServer {}}+ /** Used for debugging */protected void printLayout() throws Exception {rootClient.printLayoutToStream(System.out);}@@ -873,7 +735,7 @@ public class ZkTestServer {"ZkTestServer requires the 'stat' command, temporarily manipulating your whitelist");System.setProperty(ZK_WHITELIST_PROPERTY, "*");FourLetterCommands.resetWhiteList();- // This call to isEnabled should force ZK to "re-read" the system property in it's static+ // This call to isEnabled should force ZK to "re-read" the system property in its static// vrsassertTrue("Temporary manipulation of ZK Whitelist didn't work?",diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.javaindex 2254c7311a0..af8f5dbc3ce 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java@@ -195,7 +195,7 @@ public abstract class AbstractBackupRepositoryTest extends SolrTestCaseJ4 {}@Test- public void testDirectoryCreationFailsIfParentDoesntExist() throws Exception {+ public void testDirectoryCreationFailsIfParentDoesNotExist() throws Exception {try (BackupRepository repo = getRepository()) {final URI nonExistentParentUri = repo.resolve(getBaseUri(), "nonExistentParent");final URI nestedUri = repo.resolve(nonExistentParentUri, "childDirectoryToCreate");diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.javaindex 5dc62e94ed2..a54b2af37b3 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java@@ -64,8 +64,6 @@ public abstract class AbstractCloudBackupRestoreTestCase extends SolrCloudTestCaprivate static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());protected static final int NUM_SHARDS = 2; // granted we sometimes shard split to get more- protected static final int NUM_SPLIT_SHARDS =- 3; // We always split shard1 so total shards post split will be 3protected static final String BACKUPNAME_PREFIX = "mytestbackup";int replFactor;@@ -340,19 +338,19 @@ public abstract class AbstractCloudBackupRestoreTestCase extends SolrCloudTestCaString restoreCollectionName = collectionName + "_restored";boolean sameConfig = random().nextBoolean();- int restoreReplcationFactor = replFactor;+ int restoreReplicationFactor = replFactor;int restoreTlogReplicas = numTlogReplicas;int restorePullReplicas = numPullReplicas;boolean setExternalReplicationFactor = false;if (random().nextBoolean()) { // Override replicationFactor / tLogReplicas / pullReplicassetExternalReplicationFactor = true;restoreTlogReplicas = TestUtil.nextInt(random(), 0, 1);- restoreReplcationFactor = TestUtil.nextInt(random(), 1, 2);+ restoreReplicationFactor = TestUtil.nextInt(random(), 1, 2);restorePullReplicas = TestUtil.nextInt(random(), 0, 1);}int numShards = backupCollection.getActiveSlices().size();- int restoreReplFactor = restoreReplcationFactor + restoreTlogReplicas + restorePullReplicas;+ int restoreReplFactor = restoreReplicationFactor + restoreTlogReplicas + restorePullReplicas;CollectionAdminRequest.Restore restore =CollectionAdminRequest.restoreCollection(restoreCollectionName, backupName)@@ -361,7 +359,7 @@ public abstract class AbstractCloudBackupRestoreTestCase extends SolrCloudTestCa// explicitly specify the replicationFactor/pullReplicas/nrtReplicas/tlogReplicas.if (setExternalReplicationFactor) {- restore.setReplicationFactor(restoreReplcationFactor);+ restore.setReplicationFactor(restoreReplicationFactor);restore.setTlogReplicas(restoreTlogReplicas);restore.setPullReplicas(restorePullReplicas);}@@ -427,11 +425,11 @@ public abstract class AbstractCloudBackupRestoreTestCase extends SolrCloudTestCaassertEquals(restoreCollection.toString(),- restoreReplcationFactor,+ restoreReplicationFactor,restoreCollection.getReplicationFactor().intValue());assertEquals(restoreCollection.toString(),- restoreReplcationFactor,+ restoreReplicationFactor,restoreCollection.getNumReplicas(Replica.Type.NRT));assertEquals(restoreCollection.toString(),diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.javaindex 1fe728e757a..d2c5ed6df91 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java@@ -20,7 +20,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;import java.io.IOException;-import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;import java.util.ArrayList;@@ -66,8 +65,6 @@ import org.apache.solr.util.TimeOut;import org.junit.After;import org.junit.BeforeClass;import org.junit.Test;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;/*** Tests the Cloud Collections API.@@ -76,7 +73,6 @@ import org.slf4j.LoggerFactory;* creation to subclasses*/public abstract class AbstractCollectionsAPIDistributedZkTestBase extends SolrCloudTestCase {- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());@BeforeClasspublic static void setupCluster() {@@ -604,7 +600,7 @@ public abstract class AbstractCollectionsAPIDistributedZkTestBase extends SolrClif (entry.getValue().size() > 1) {fail("We have shards using the same indexDir. E.g. shards "- + entry.getValue().toString()+ + entry.getValue()+ " all use indexDir "+ entry.getKey());}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.javaindex e5d501b8528..0df483d8b35 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java@@ -310,7 +310,7 @@ public abstract class AbstractIncrementalBackupTest extends SolrCloudTestCase {simpleRestoreAndCheckDocCount(solrClient, backupLocation, backupName);// test purge backups- // purging first since there may corrupted files were uploaded+ // purging first since there may be corrupted files that were uploadedresp =CollectionAdminRequest.deleteBackupPurgeUnusedFiles(backupName).setRepositoryName(BACKUP_REPO_NAME)@@ -638,7 +638,7 @@ public abstract class AbstractIncrementalBackupTest extends SolrCloudTestCase {this.maxNumberOfBackupToKeep = maxNumberOfBackupToKeep;}- @SuppressWarnings({"rawtypes", "unchecked"})+ @SuppressWarnings({"unchecked"})private void backupThenWait() throws SolrServerException, IOException {CollectionAdminRequest.Backup backup =CollectionAdminRequest.backupCollection(getCollectionName(), backupName)@@ -661,7 +661,6 @@ public abstract class AbstractIncrementalBackupTest extends SolrCloudTestCase {Map<String, Object> resp = (Map<String, Object>) rsp.getResponse().get("response");numBackup++;assertEquals(numBackup, resp.get("backupId"));- ;}}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.javaindex eae246c0486..d0dce8e9b6d 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java@@ -82,7 +82,7 @@ public abstract class AbstractInstallShardTest extends SolrCloudTestCase {}@Before- public void clearCollsToDelete() {+ public void clearCollectionsToDelete() {collectionsToDelete = new ArrayList<>();}@@ -233,7 +233,7 @@ public abstract class AbstractInstallShardTest extends SolrCloudTestCase {deleteAfterTest(collectionName);enableReadOnly(collectionName);- runParallelShardInstalls(collectionName, multiShardUris);+ runParallelShardInstalls(collectionName);assertCollectionHasNumDocs(collectionName, multiShardNumDocs);}@@ -382,8 +382,7 @@ public abstract class AbstractInstallShardTest extends SolrCloudTestCase {.process(cluster.getSolrClient());}- private void runParallelShardInstalls(String collectionName, URI[] dataLocations)- throws Exception {+ private void runParallelShardInstalls(String collectionName) throws Exception {final SolrClient solrClient = cluster.getSolrClient();final List<Callable<Exception>> tasks = new ArrayList<>();for (int i = 0; i < multiShardUris.length; i++) {diff --git a/solr/test-framework/src/java/org/apache/solr/cluster/placement/Builders.java b/solr/test-framework/src/java/org/apache/solr/cluster/placement/Builders.javaindex 7185472b7a9..03cc9522838 100644--- a/solr/test-framework/src/java/org/apache/solr/cluster/placement/Builders.java+++ b/solr/test-framework/src/java/org/apache/solr/cluster/placement/Builders.java@@ -325,8 +325,8 @@ public class Builders {replicas.add(replicaBuilder);// No way to specify which replica is the leader. Could be done by adding a "*" to the- // replica definition for example in the passed shardsReplicas but not implementing this- // until it is needed :)+ // replica definition for example in the provided shardsReplicas, but not implementing+ // this until it is needed :)if (leader == null && type != Replica.ReplicaType.PULL) {leader = replicaBuilder;}@@ -344,7 +344,7 @@ public class Builders {* Initializes shard and replica builders for the collection based on passed parameters.* Replicas are assigned round-robin to the nodes. The shard leader is the first NRT replica of* each shard (or first TLOG is no NRT). Shard and replica configuration can be modified- * afterwards, the returned builder hierarchy is a convenient starting point.+ * afterward, the returned builder hierarchy is a convenient starting point.** @param countShards number of shards to create* @param countNrtReplicas number of NRT replicas per shard@@ -366,7 +366,7 @@ public class Builders {* Initializes shard and replica builders for the collection based on passed parameters.* Replicas are assigned round-robin to the nodes. The shard leader is the first NRT replica of* each shard (or first TLOG is no NRT). Shard and replica configuration can be modified- * afterwards, the returned builder hierarchy is a convenient starting point.+ * afterward, the returned builder hierarchy is a convenient starting point.** @param countShards number of shards to create* @param countNrtReplicas number of NRT replicas per sharddiff --git a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.javaindex 4ba58c5645b..ba5a82112d4 100644--- a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java@@ -89,7 +89,7 @@ public class MockDirectoryFactory extends EphemeralDirectoryFactory {@Overridepublic boolean isAbsolute(String path) {// TODO: kind of a hack - we don't know what the delegate is, so- // we treat it as file based since this works on most ephem impls+ // we treat it as file based since this works on most ephemeral implementationsreturn Path.of(path).isAbsolute();}}diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java b/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.javaindex 30f8cdd266c..6f6eb5b9de8 100644--- a/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java@@ -51,7 +51,7 @@ public class MockFSDirectoryFactory extends StandardDirectoryFactory {@Overridepublic boolean isAbsolute(String path) {// TODO: kind of a hack - we don't know what the delegate is, so- // we treat it as file based since this works on most ephem impls+ // we treat it as file based since this works on most ephemeral implementationsreturn Path.of(path).isAbsolute();}diff --git a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.javaindex 86a379e248e..522ec25491e 100644--- a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java+++ b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java@@ -112,7 +112,6 @@ public class JettySolrRunner {volatile FilterHolder dispatchFilter;volatile FilterHolder debugFilter;- private boolean waitOnSolr = false;private int jettyPort = -1;private final JettyConfig config;@@ -370,7 +369,7 @@ public class JettySolrRunner {new CoreContainerProvider() {@Overridepublic void contextInitialized(ServletContextEvent event) {- // awkwardly, parts of Solr want to know the port but we don't know that until now+ // awkwardly, parts of Solr want to know the port, but we don't know that until nowjettyPort = getFirstConnectorPort();int port = jettyPort;if (proxyPort != -1) port = proxyPort;@@ -514,7 +513,6 @@ public class JettySolrRunner {// if started before, make a new serverif (startedBefore) {- waitOnSolr = false;init(port);} else {startedBefore = true;@@ -701,7 +699,7 @@ public class JettySolrRunner {}}- public void dumpCoresInfo(PrintStream pw) throws IOException {+ public void dumpCoresInfo(PrintStream pw) {if (getCoreContainer() != null) {final var coreStatusReq = new CoresApi.GetAllCoreStatus();coreStatusReq.setIndexInfo(true);@@ -755,7 +753,7 @@ public class JettySolrRunner {}/**- * Sets the port of a local socket proxy that sits infront of this server; if set then all client+ * Sets the port of a local socket proxy that sits in front of this server; if set then all client* traffic will flow through the proxy, giving us the ability to simulate network partitions very* easily.*/@@ -767,9 +765,7 @@ public class JettySolrRunner {public URL getBaseUrl() {try {return new URI(protocol, null, host, jettyPort, "/solr", null, null).toURL();- } catch (URISyntaxException e) {- throw new RuntimeException(e);- } catch (MalformedURLException e) {+ } catch (URISyntaxException | MalformedURLException e) {throw new RuntimeException(e);}}@@ -777,9 +773,7 @@ public class JettySolrRunner {public URL getBaseURLV2() {try {return new URI(protocol, null, host, jettyPort, "/api", null, null).toURL();- } catch (MalformedURLException e) {- throw new RuntimeException(e);- } catch (URISyntaxException e) {+ } catch (MalformedURLException | URISyntaxException e) {throw new RuntimeException(e);}}@@ -791,9 +785,7 @@ public class JettySolrRunner {public URL getProxyBaseUrl() {try {return new URI(protocol, null, host, getLocalPort(), "/solr", null, null).toURL();- } catch (MalformedURLException e) {- throw new RuntimeException(e);- } catch (URISyntaxException e) {+ } catch (MalformedURLException | URISyntaxException e) {throw new RuntimeException(e);}}diff --git a/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java b/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.javaindex 6210fe19477..ca4ecde51d0 100644--- a/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java+++ b/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java@@ -61,7 +61,7 @@ public final class BackupStatusChecker {}/**- * Convinience wrapper+ * Convenience wrapper** @see #waitForBackupSuccess(String,TimeOut)*/@@ -72,7 +72,7 @@ public final class BackupStatusChecker {}/**- * Polls the replication handler's status until the it reports that the specified backupName is+ * Polls the replication handler's status until it reports that the specified backupName is* completed as a <code>"success"</code> (in which case the method returns the directoryName of* the backup) or either <code>"exception"</code> is reported or the <code>timeOut</code> expires* (in either case an assertion is thrown)@@ -105,7 +105,7 @@ public final class BackupStatusChecker {}/**- * Convinience wrapper+ * Convenience wrapper** @see #waitForDifferentBackupDir(String,TimeOut)*/@@ -117,20 +117,19 @@ public final class BackupStatusChecker {}/**- * Polls the replication handler's status until the it reports that <em>any</em> backup has- * completed as a <code>"success"</code> with a different <code>"directoryName"</code> then the- * one specified (in which case the method returns the new directoryName) or either an <code>+ * Polls the replication handler's status until it reports that <em>any</em> backup has completed+ * as a <code>"success"</code> with a different <code>"directoryName"</code> then the one+ * specified (in which case the method returns the new directoryName) or either an <code>* "exception"</code> is reported or the <code>timeOut</code> expires (in either case an assertion* is thrown)** <p><b>NOTE:</b> this method is <em>NOT</em> suitable/safe to use in a test where multiple* backups are being taken/deleted concurrently, because the replication handler API provides no- * reliable way to determine if the most recently reported status to the a particular backup- * request.+ * reliable way to determine if the most recently reported status to a particular backup request.** @param directoryName to compare to, may be null* @param timeOut limiting how long we wait- * @return the (new) directoryName of the latests successful backup+ * @return the (new) directoryName of the latest successful backup* @see #checkBackupSuccess()*/public String waitForDifferentBackupDir(final String directoryName, final TimeOut timeOut)@@ -154,17 +153,16 @@ public final class BackupStatusChecker {}/**- * Does a single check of the replication handler's status to determine if the mostrecently+ * Does a single check of the replication handler's status to determine if the most recently* completed backup was a success. Throws a test assertion failure if any <code>"exception"</code>* message is ever encountered (The Replication Handler API does not make it possible to know* <em>which</em> backup this exception was related to)** <p><b>NOTE:</b> this method is <em>NOT</em> suitable/safe to use in a test where multiple* backups are being taken/deleted concurrently, because the replication handler API provides no- * reliable way to determine if the most recently reported status to the a particular backup- * request.+ * reliable way to determine if the most recently reported status to a particular backup request.*- * @return the "directoryName" of the backup if the response indicates that a is completed+ * @return the "directoryName" of the backup if the response indicates that is completed* successfully, otherwise null*/public String checkBackupSuccess() throws Exception {@@ -187,7 +185,7 @@ public final class BackupStatusChecker {return _checkBackupSuccess(backupName);}- /** Helper method that works with either named or unnamemed backups */+ /** Helper method that works with either named or unnamed backups */private String _checkBackupSuccess(final String backupName) throws Exception {final String label = (null == backupName ? "latest backup" : backupName);final SimpleSolrResponse rsp =@@ -220,7 +218,7 @@ public final class BackupStatusChecker {}/**- * Convinience wrapper+ * Convenience wrapper** @see #waitForBackupDeletionSuccess(String,TimeOut)*/@@ -231,7 +229,7 @@ public final class BackupStatusChecker {}/**- * Polls the replication handler's status until the it reports that the specified backupName is+ * Polls the replication handler's status until it reports that the specified backupName is* deleted or either <code>"Unable to delete"</code> status is reported or the <code>timeOut* </code> expires (in either case an assertion is thrown)*@@ -246,7 +244,7 @@ public final class BackupStatusChecker {*/public void waitForBackupDeletionSuccess(final String backupName, final TimeOut timeOut)throws Exception {- assertNotNull("backumpName must not be null", backupName);+ assertNotNull("backupName must not be null", backupName);while (!timeOut.hasTimedOut()) {if (checkBackupDeletionSuccess(backupName)) {return;@@ -270,7 +268,7 @@ public final class BackupStatusChecker {* @see #waitForBackupDeletionSuccess(String,TimeOut)*/public boolean checkBackupDeletionSuccess(final String backupName) throws Exception {- assertNotNull("backumpName must not be null", backupName);+ assertNotNull("backupName must not be null", backupName);final SimpleSolrResponse rsp =new GenericSolrRequest(GenericSolrRequest.METHOD.GET,diff --git a/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java b/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.javaindex d8c1e039f78..cfafc590cd1 100644--- a/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java@@ -157,7 +157,6 @@ public class TrackingShardHandlerFactory extends HttpShardHandlerFactory {ShardHandlerFactory factory = container.getShardHandlerFactory();assert factory instanceof TrackingShardHandlerFactory: "not a TrackingShardHandlerFactory: " + factory.getClass();- @SuppressWarnings("resource")TrackingShardHandlerFactory trackingShardHandlerFactory =(TrackingShardHandlerFactory) factory;trackingShardHandlerFactory.setTrackingQueue(queue);diff --git a/solr/test-framework/src/java/org/apache/solr/search/CallerSpecificQueryLimit.java b/solr/test-framework/src/java/org/apache/solr/search/CallerSpecificQueryLimit.javaindex 559a798296b..d78cb4fbad8 100644--- a/solr/test-framework/src/java/org/apache/solr/search/CallerSpecificQueryLimit.java+++ b/solr/test-framework/src/java/org/apache/solr/search/CallerSpecificQueryLimit.java@@ -16,12 +16,9 @@*/package org.apache.solr.search;-import java.lang.invoke.MethodHandles;import java.util.Collection;import java.util.Set;import org.apache.solr.util.CallerMatcher;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;/*** Helper class to simulate query timeouts at specific points in various components that call {@link@@ -29,8 +26,6 @@ import org.slf4j.LoggerFactory;* information and enforce the count limits.*/public class CallerSpecificQueryLimit implements QueryLimit {- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());-private final CallerMatcher callerMatcher;/**diff --git a/solr/test-framework/src/java/org/apache/solr/search/facet/DebugAgg.java b/solr/test-framework/src/java/org/apache/solr/search/facet/DebugAgg.javaindex b5c25e6a67d..fe57495e6a9 100644--- a/solr/test-framework/src/java/org/apache/solr/search/facet/DebugAgg.java+++ b/solr/test-framework/src/java/org/apache/solr/search/facet/DebugAgg.java@@ -38,14 +38,12 @@ class DebugAgg extends AggValueSource {parses.incrementAndGet();final String what = fp.hasMoreArguments() ? fp.parseId() : "wrap";- switch (what) {- case "wrap":- return new DebugAgg(fp);- case "numShards":- return new DebugAggNumShards();- default: /* No-Op */- }- throw new RuntimeException("No idea what to do with " + what);+ /* No-Op */+ return switch (what) {+ case "wrap" -> new DebugAgg(fp);+ case "numShards" -> new DebugAggNumShards();+ default -> throw new RuntimeException("No idea what to do with " + what);+ };}}@@ -172,7 +170,7 @@ class DebugAgg extends AggValueSource {@Overridepublic SlotAcc createSlotAcc(FacetContext fcontext, long numDocs, int numSlots) {- return new NumShardsAcc(fcontext, numDocs, numSlots);+ return new NumShardsAcc(fcontext);}@Override@@ -186,7 +184,7 @@ class DebugAgg extends AggValueSource {}public static class NumShardsAcc extends SlotAcc {- public NumShardsAcc(FacetContext fcontext, long numDocs, int numSlots) {+ public NumShardsAcc(FacetContext fcontext) {super(fcontext);}diff --git a/solr/test-framework/src/java/org/apache/solr/update/processor/RecordingUpdateProcessorFactory.java b/solr/test-framework/src/java/org/apache/solr/update/processor/RecordingUpdateProcessorFactory.javaindex 3bac27571d2..7e3d8c42642 100644--- a/solr/test-framework/src/java/org/apache/solr/update/processor/RecordingUpdateProcessorFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/update/processor/RecordingUpdateProcessorFactory.java@@ -61,7 +61,6 @@ public final class RecordingUpdateProcessorFactory extends UpdateRequestProcesso}@Override- @SuppressWarnings("resource")public synchronized UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {return recording ? new RecordingUpdateRequestProcessor(commandQueue, next) : next;diff --git a/solr/test-framework/src/java/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java b/solr/test-framework/src/java/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.javaindex 89efbdbe699..96f42e3b379 100644--- a/solr/test-framework/src/java/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java@@ -99,7 +99,6 @@ public final class TrackingUpdateProcessorFactory extends UpdateRequestProcessor}@Override- @SuppressWarnings("resource")public synchronized UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {final List<UpdateCommand> commands = groupToCommands.get(group);diff --git a/solr/test-framework/src/java/org/apache/solr/update/processor/UpdateProcessorTestBase.java b/solr/test-framework/src/java/org/apache/solr/update/processor/UpdateProcessorTestBase.javaindex 97227e5e3a0..5afa8e6b0b7 100644--- a/solr/test-framework/src/java/org/apache/solr/update/processor/UpdateProcessorTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/update/processor/UpdateProcessorTestBase.java@@ -66,7 +66,7 @@ public class UpdateProcessorTestBase extends SolrTestCaseJ4 {UpdateRequestProcessor processor = pc.createProcessor(req, rsp);if (null != processor) {- // test chain might be empty or short circuited.+ // test chain might be empty or short-circuited.processor.processAdd(cmd);}diff --git a/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.java b/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.javadeleted file mode 100644index c04100d60a4..00000000000--- a/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.java+++ /dev/null@@ -1,36 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.solr.util;--import com.carrotsearch.randomizedtesting.ThreadFilter;--public class BadZookeeperThreadsFilter implements ThreadFilter {-- @Override- public boolean reject(Thread t) {- String name = t.getName();-- StackTraceElement[] stack = t.getStackTrace();- if (name.startsWith("Thread-")- && stack.length > 1- && stack[stack.length - 2].getClassName().equals("org.apache.zookeeper.Login$1")) {- return true; // see ZOOKEEPER-2100- }-- return false;- }-}diff --git a/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.javaindex 91b411168c1..c88d7ba690a 100644--- a/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java+++ b/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java@@ -117,7 +117,7 @@ public abstract class BaseTestHarness {}/**- * A helper that creates an xml <doc> containing all of the fields and values specified+ * A helper that creates a xml <doc> containing all fields and values specified** @param fieldsAndValues 0 and Even numbered args are fields names odds are field values.*/@@ -185,7 +185,7 @@ public abstract class BaseTestHarness {}/**- * Helper that returns an <optimize> String with optional key/val pairs.+ * Helper that returns a <optimize> String with optional key/val pairs.** @param args 0 and Even numbered args are params, Odd numbered args are values.*/@@ -204,7 +204,7 @@ public abstract class BaseTestHarness {}/**- * Helper that returns an <commit> String with optional key/val pairs.+ * Helper that returns a <commit> String with optional key/val pairs.** @param args 0 and Even numbered args are params, Odd numbered args are values.*/diff --git a/solr/test-framework/src/java/org/apache/solr/util/CallerMatcher.java b/solr/test-framework/src/java/org/apache/solr/util/CallerMatcher.javaindex 22030d357e3..dc6ba4b49af 100644--- a/solr/test-framework/src/java/org/apache/solr/util/CallerMatcher.java+++ b/solr/test-framework/src/java/org/apache/solr/util/CallerMatcher.java@@ -72,7 +72,7 @@ public class CallerMatcher {** @param callerExprs list of expressions in the format of <code>* ( simpleClassName[.methodName] | * )[:NNN]</code>. If the list is empty or null then the- * first call to {@link #checkCaller()} ()} from any caller will match.+ * first call to {@link #checkCaller()} from any caller will match.*/public CallerMatcher(Collection<String> callerExprs, Collection<String> excludeExprs) {for (String callerExpr : callerExprs) {diff --git a/solr/test-framework/src/java/org/apache/solr/util/DirectoryUtil.java b/solr/test-framework/src/java/org/apache/solr/util/DirectoryUtil.javaindex 6a341dcecdd..d3c74b5d386 100644--- a/solr/test-framework/src/java/org/apache/solr/util/DirectoryUtil.java+++ b/solr/test-framework/src/java/org/apache/solr/util/DirectoryUtil.java@@ -34,7 +34,7 @@ public class DirectoryUtil {* </pre>** will copy the contents of src directly into dst. This will not create a new "src" folder inside- * of dst.+ * the dst.*/public static void copyDirectoryContents(final Path source, final Path destination)throws IOException {diff --git a/solr/test-framework/src/java/org/apache/solr/util/ErrorLogMuter.java b/solr/test-framework/src/java/org/apache/solr/util/ErrorLogMuter.javaindex 4de7e2ec1cf..e02fadd460f 100644--- a/solr/test-framework/src/java/org/apache/solr/util/ErrorLogMuter.java+++ b/solr/test-framework/src/java/org/apache/solr/util/ErrorLogMuter.java@@ -50,13 +50,14 @@ import org.apache.solr.common.util.SuppressForbidden;* Throwable#getCause}es of an included <code>Throwable</code>.** <p>Matching ERROR messages are "muted" by filtering them out of the ROOT logger. Any Appenders- * attached to more specific Loggers may still include these "muted" ERRROR messages.+ * attached to more specific Loggers may still include these "muted" ERROR messages.*/@SuppressForbidden(reason = "We need to use log4J2 classes directly to check that the ErrorLogMuter is working")public final class ErrorLogMuter implements Closeable, AutoCloseable {- // far easier to use FQN for our (one) slf4j Logger then to use a FQN every time we refe to log4j2+ // far easier to use FQN for our (one) slf4j Logger then to use a FQN every time we refer to+ // log4j2// Loggerprivate static final org.slf4j.Logger log =org.slf4j.LoggerFactory.getLogger(@@ -69,7 +70,7 @@ public final class ErrorLogMuter implements Closeable, AutoCloseable {*/private static final AtomicInteger ID_GEN = new AtomicInteger(0);- /** generate a unique name for each muter to use in it's own lifecycle logging */+ /** generate a unique name for each muter to use in its own lifecycle logging */private static String createName(final String type) {return MethodHandles.lookup().lookupClass().getSimpleName()+ "-"@@ -134,8 +135,8 @@ public final class ErrorLogMuter implements Closeable, AutoCloseable {}/**- * The number of ERROR messages muted (by this instance) so far in it's lifecycle. This number may- * be less then the number of ERROR messages expected if multiple ErrorLogMuter objects are in use+ * The number of ERROR messages muted (by this instance) so far in its lifecycle. This number may+ * be less than the number of ERROR messages expected if multiple ErrorLogMuter objects are in use* which match the same ERROR log messages*/public int getCount() {@@ -144,11 +145,11 @@ public final class ErrorLogMuter implements Closeable, AutoCloseable {@Overridepublic void close() {- if (!closed.getAndSet(true)) { // Don't muck with log4j if we accidently get a double close+ if (!closed.getAndSet(true)) { // Don't muck with log4j if we accidentally get a double closeCTX.getConfiguration().getRootLogger().removeFilter(rootFilter);CTX.updateLoggers();if (log.isInfoEnabled()) {- log.info("Closing {} after mutting {} log messages", this.name, getCount());+ log.info("Closing {} after muting {} log messages", this.name, getCount());}}}@@ -196,7 +197,8 @@ public final class ErrorLogMuter implements Closeable, AutoCloseable {// NOTE: This is inspired by log4j's RegexFilter, but with an eye to being more "garbage-free"// friendly- // Oddly, StringMatchFilter does things differnetly and acts like it needs to (re?) format msgs+ // Oddly, StringMatchFilter does things differently and acts like it needs to (re?) format+ // messages// when params are provided// Since RegexFilter has tests, and StringMatchFilter doesn't, we assume RegexFilter knows what// it's doing...@@ -373,7 +375,7 @@ public final class ErrorLogMuter implements Closeable, AutoCloseable {public Result filter(LogEvent event) {// NOTE: For our usage, we're not worried about needing to filter LogEvents rom remote JVMs// with ThrowableProxy- // stand ins for Throwabls that don't exist in our classloader...+ // stand ins for Throwables that don't exist in our classloader...return doFilter(event.getLevel(), event.getMessage().getFormattedMessage(), event.getThrown());}diff --git a/solr/test-framework/src/java/org/apache/solr/util/LogListener.java b/solr/test-framework/src/java/org/apache/solr/util/LogListener.javaindex 17039025517..0646d103f0d 100644--- a/solr/test-framework/src/java/org/apache/solr/util/LogListener.java+++ b/solr/test-framework/src/java/org/apache/solr/util/LogListener.java@@ -52,7 +52,7 @@ import org.apache.solr.common.util.SuppressForbidden;** <p><code>* // simplest possible usage...- * // Listen for any erors from the SolrCore logger, and assert that there are none...+ * // Listen for any errors from the SolrCore logger, and assert that there are none...* try (LogListener errLog = LogListener.error(SolrCore.class)) {* // ... some test code ...*@@ -64,7 +64,7 @@ import org.apache.solr.common.util.SuppressForbidden;* try (LogListener secWarnLog = LogListener.warn("org.apache.solr.security").substring("PKI")) {* // ... some test code ...*- * // convinience method for only dealing with Message String of the LogEvent+ * // convenience method for only dealing with Message String of the LogEvent* assertThat(secWarnLog.pollMessage(), containsString("hoss"));* assertThat(secWarnLog.getQueue().isEmpty()); // no other WARNings matching PKI*@@ -78,9 +78,9 @@ import org.apache.solr.common.util.SuppressForbidden;* </code>** <p>Each <code>LogListener</code> captures & queues matching Log events until it is {@link- * #close()}ed. By default the Queue is bounded at a max capacity of 100. Regardless of what Queue- * is used, if a Log event can't be queued (due to capacity limiting), or if events are still left- * in the Queue when the listener is closed, then the {@link #close()} method will cause a test+ * #close()}ed. The default Queue is bounded at a max capacity of 100. Regardless of what Queue is+ * used, if a Log event can't be queued (due to capacity limiting), or if events are still left in+ * the Queue when the listener is closed, then the {@link #close()} method will cause a test* failure.** <p>Filtering methods such {@link #substring} and {@link #regex} can be used to restrict which Log@@ -97,7 +97,8 @@ import org.apache.solr.common.util.SuppressForbidden;@SuppressForbidden(reason = "We need to use log4J2 classes directly")public final class LogListener implements Closeable, AutoCloseable {- // far easier to use FQN for our (one) slf4j Logger then to use a FQN every time we refe to log4j2+ // far easier to use FQN for our (one) slf4j Logger then to use a FQN every time we refer to+ // log4j2// Loggerprivate static final org.slf4j.Logger log =org.slf4j.LoggerFactory.getLogger(@@ -110,7 +111,7 @@ public final class LogListener implements Closeable, AutoCloseable {*/private static final AtomicInteger ID_GEN = new AtomicInteger(0);- /** generate a unique name for each instance to use in it's own lifecycle logging */+ /** generate a unique name for each instance to use in its own lifecycle logging */private static String createName(final Level level) {return MethodHandles.lookup().lookupClass().getSimpleName()+ "-"@@ -217,8 +218,9 @@ public final class LogListener implements Closeable, AutoCloseable {}// Note: we don't just pass our level to addAppender, because that would only require it be "as- // specifc"- // we use a wrapper that requres an exact level match (and other predicates can be added to this+ // specific"+ // we use a wrapper that requires an exact level match (and other predicates can be added to+ // this// filter later)...this.filter = new MutablePredicateFilter(level);this.loggerAppender = new QueueAppender(name);@@ -229,7 +231,7 @@ public final class LogListener implements Closeable, AutoCloseable {@Overridepublic void close() {- if (!closed.getAndSet(true)) { // Don't muck with log4j if we accidently get a double close+ if (!closed.getAndSet(true)) { // Don't muck with log4j if we accidentally get a double closefinal LoggerConfig loggerConfig = CTX.getConfiguration().getLoggerConfig(loggerName);loggerConfig.removeAppender(loggerAppender.getName());if (null != resetLevelWhenDone) {@@ -243,7 +245,7 @@ public final class LogListener implements Closeable, AutoCloseable {}assertEquals(this.name- + " processed log events that it could not record beause queue capacity was exceeded",+ + " processed log events that it could not record because queue capacity was exceeded",0,loggerAppender.getNumCapacityExceeded());assertEquals(@@ -364,7 +366,7 @@ public final class LogListener implements Closeable, AutoCloseable {* Convenience method for tests that want to assert things about the (formated) message string at* the head of the queue, waiting up to the specified timeout for the message to arrive.*- * @param timeout the duation value+ * @param timeout the duration value* @param unit the duration unit* @return the formatted message string of head of the queue, or null if the queue remained empty* until the specified timeout.@@ -381,7 +383,7 @@ public final class LogListener implements Closeable, AutoCloseable {}/**- * The total number of Log events so far processed by this instance, regardless of wether they+ * The total number of Log events so far processed by this instance, regardless of whether they* have already been removed from the queue, or if they could not be added to the queue due to* capacity restrictions.*/@@ -589,7 +591,7 @@ public final class LogListener implements Closeable, AutoCloseable {public Result filter(LogEvent event) {// NOTE: For our usage, we're not worried about needing to filter LogEvents rom remote JVMs// with ThrowableProxy- // stand ins for Throwabls that don't exist in our classloader...+ // stand ins for Throwables that don't exist in our classloader...return doFilter(event.getLevel(), event.getMessage().getFormattedMessage(), event.getThrown());}diff --git a/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.java b/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.javadeleted file mode 100644index 06fcc1796be..00000000000--- a/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.java+++ /dev/null@@ -1,39 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.solr.util;--import java.nio.file.Path;-import java.util.Collections;-import org.apache.solr.core.CoreContainer;-import org.apache.solr.core.CoreDescriptor;--public class MockCoreContainer extends CoreContainer {- public static class MockCoreDescriptor extends CoreDescriptor {- public MockCoreDescriptor() {- super("mock", Path.of("path").toAbsolutePath(), Collections.emptyMap(), null, null);- }- }-- public MockCoreContainer() {- super(new Object());- }-- @Override- public Path getCoreRootDirectory() {- return Path.of("coreroot");- }-}diff --git a/solr/test-framework/src/java/org/apache/solr/util/NotSecurePseudoRandomSpi.java b/solr/test-framework/src/java/org/apache/solr/util/NotSecurePseudoRandomSpi.javaindex a5e0bc42a91..b5441d350c6 100644--- a/solr/test-framework/src/java/org/apache/solr/util/NotSecurePseudoRandomSpi.java+++ b/solr/test-framework/src/java/org/apache/solr/util/NotSecurePseudoRandomSpi.java@@ -16,7 +16,6 @@*/package org.apache.solr.util;-import java.security.SecureRandomParameters;import java.security.SecureRandomSpi;import java.util.Random;import java.util.concurrent.ThreadLocalRandom;@@ -24,7 +23,7 @@ import java.util.concurrent.ThreadLocalRandom;/*** A mocked up instance of SecureRandom that just uses {@link Random} under the covers. This is to* prevent blocking issues that arise in platform default SecureRandom instances due to too many- * instances / not enough random entropy. Tests do not need secure SSL.+ * instances / not enough random entropy. Tests do not need to use a secure SSL.*/public class NotSecurePseudoRandomSpi extends SecureRandomSpi {@@ -42,47 +41,19 @@ public class NotSecurePseudoRandomSpi extends SecureRandomSpi {}/**- * Helper method that can be used to fill an array with non-zero data. (Attempted workarround of+ * Helper method that can be used to fill an array with non-zero data. (Attempted workaround of* Solaris SSL Padding bug: SOLR-9068)*/- private static final byte[] fillData(byte[] data) {+ private static void fillData(byte[] data) {ThreadLocalRandom.current().nextBytes(data);- return data;}public NotSecurePseudoRandomSpi() {super();}- /** returns a new byte[] filled with static data */- public byte[] generateSeed(int numBytes) {- return fillData(new byte[numBytes]);- }-/** fills the byte[] with static data */public void nextBytes(byte[] bytes) {fillData(bytes);}-- public void nextBytes(byte[] bytes, SecureRandomParameters params) {- fillData(bytes);- }-- /** NOOP */- public void setSeed(byte[] seed) {- /* NOOP */- }-- /** NOOP */- public void setSeed(long seed) {- /* NOOP */- }-- public void reseed() {- /* NOOP */- }-- public void reseed(SecureRandomParameters params) {- /* NOOP */- }}diff --git a/solr/test-framework/src/java/org/apache/solr/util/QueryMatchers.java b/solr/test-framework/src/java/org/apache/solr/util/QueryMatchers.javaindex bbe78b2027c..a5b236a7917 100644--- a/solr/test-framework/src/java/org/apache/solr/util/QueryMatchers.java+++ b/solr/test-framework/src/java/org/apache/solr/util/QueryMatchers.java@@ -58,7 +58,7 @@ public class QueryMatchers {/*** Matches is a Query object's toString result is equal to this query string. A useful shortcut- * when constructing complex queries with deterministic string repr+ * when constructing complex queries with deterministic string representation.** <p>Note: Do not use this in place of DisjunctionMaxQuery, but safe to use for the disjunct* clausesdiff --git a/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java b/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.javaindex 475f49d6aec..54e19285363 100644--- a/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java+++ b/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java@@ -42,12 +42,12 @@ public @interface RandomizeSSL {// we don't choose ssl that often by default because of SOLR-5776public static final double DEFAULT_ODDS = 0.2D;- /** Comment to inlcude when logging details of SSL randomization */+ /** Comment to include when logging details of SSL randomization */public String reason() default "";/*** Odds (as ratio relative to 1) that SSL should be selected in a typical run. Must either be- * betwen 0.0 and 1.0 (inclusively) or NaN in which case a sensible should be used. Actual Odds+ * between 0.0 and 1.0 (inclusively) or NaN in which case a sensible should be used. Actual Odds* used for randomization may be higher depending on runner options such as <code>tests.multiplier* </code> or <code>tests.nightly</code>*@@ -59,7 +59,7 @@ public @interface RandomizeSSL {/*** Odds (as ratio relative to 1) that SSL should be selected in a typical run. Must either be- * betwen 0.0 and 1.0 (inclusively) or NaN in which case the effective value of {@link #ssl}+ * between 0.0 and 1.0 (inclusively) or NaN in which case the effective value of {@link #ssl}* should be used. Actual Odds used for randomization may be higher depending on runner options* such as <code>tests.multiplier</code> or <code>tests.nightly</code>*@@ -143,14 +143,14 @@ public @interface RandomizeSSL {assert 0 < multiplier;- // negate the odds so we can then divide it by our multipling factors+ // negate the odds so we can then divide it by our multiplying factors// to increase the final oddsreturn 1.0D- ((1.0D - declaredOdds) / ((nightly ? 1.1D : 1.0D) * (1.0D + Math.log(multiplier))));}/** Returns an SSLRandomizer suitable for the specified (test) class */- public static final SSLRandomizer getSSLRandomizerForClass(Class<?> clazz) {+ public static SSLRandomizer getSSLRandomizerForClass(Class<?> clazz) {final SuppressSSL suppressSSL = clazz.getAnnotation(SuppressSSL.class);if (null != suppressSSL) {@@ -172,24 +172,18 @@ public @interface RandomizeSSL {final double def = Double.isNaN(randomizeSSL.value()) ? DEFAULT_ODDS : randomizeSSL.value();if (def < 0.0D || 1.0D < def) {throw new IllegalArgumentException(- clazz.getName()- + ": default value is not a ratio between 0 and 1: "- + randomizeSSL.toString());+ clazz.getName() + ": default value is not a ratio between 0 and 1: " + randomizeSSL);}final double ssl = Double.isNaN(randomizeSSL.ssl()) ? def : randomizeSSL.ssl();if (ssl < 0.0D || 1.0D < ssl) {throw new IllegalArgumentException(- clazz.getName()- + ": ssl value is not a ratio between 0 and 1: "- + randomizeSSL.toString());+ clazz.getName() + ": ssl value is not a ratio between 0 and 1: " + randomizeSSL);}final double clientAuth =Double.isNaN(randomizeSSL.clientAuth()) ? ssl : randomizeSSL.clientAuth();if (clientAuth < 0.0D || 1 < clientAuth) {throw new IllegalArgumentException(- clazz.getName()- + ": clientAuth value is not a ratio between 0 and 1: "- + randomizeSSL.toString());+ clazz.getName() + ": clientAuth value is not a ratio between 0 and 1: " + randomizeSSL);}return new SSLRandomizer(ssl, clientAuth, randomizeSSL.toString());}diff --git a/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.javaindex 93a2eef3a68..18c1f3355ce 100644--- a/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java+++ b/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java@@ -60,36 +60,6 @@ public class RestTestHarness extends BaseTestHarness implements Closeable {return getBaseURL().replace("/collection1", "");}- /**- * Validates an XML "query" response against an array of XPath test strings- *- * @param request the Query to process- * @return null if all good, otherwise the first test that fails.- * @exception Exception any exception in the response.- * @exception java.io.IOException if there is a problem writing the XML- */- public String validateQuery(String request, String... tests) throws Exception {-- String res = query(request);- return validateXPath(res, tests);- }-- /**- * Validates an XML PUT response against an array of XPath test strings- *- * @param request the PUT request to process- * @param content the content to send with the PUT request- * @param tests the validating XPath tests- * @return null if all good, otherwise the first test that fails.- * @exception Exception any exception in the response.- * @exception java.io.IOException if there is a problem writing the XML- */- public String validatePut(String request, String content, String... tests) throws Exception {-- String res = put(request, content);- return validateXPath(res, tests);- }-/*** Processes a "query" using a URL path (with no context path) + optional query params, e.g.* "/schema/fields?indent=off"diff --git a/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java b/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.javaindex 78be26e2e34..70f26d6405e 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java@@ -210,7 +210,7 @@ public class SSLTestConfig {** <p>NOTE: Uses a completely insecure {@link SecureRandom} instance to prevent tests from* blocking due to lack of entropy, also explicitly allows the use of self-signed certificates- * (since that's what is almost always used during testing). almost always used during testing).+ * (since that's what is almost always used during testing).*/public SSLConfig buildServerSSLConfig() {if (!isSSLMode()) {@@ -330,16 +330,16 @@ public class SSLTestConfig {/*** A mocked up instance of SecureRandom that just uses {@link Random} under the covers. This is to* prevent blocking issues that arise in platform default SecureRandom instances due to too many- * instances / not enough random entropy. Tests do not need secure SSL.+ * instances / not enough random entropy. Tests do not need to use secure SSL.*/private static class NotSecurePseudoRandom extends SecureRandom {public static final SecureRandom INSTANCE = new NotSecurePseudoRandom();/**- * Helper method that can be used to fill an array with non-zero data. (Attempted workarround of+ * Helper method that can be used to fill an array with non-zero data. (Attempted workaround of* Solaris SSL Padding bug: SOLR-9068)*/- private static final byte[] fillData(byte[] data) {+ private static byte[] fillData(byte[] data) {ThreadLocalRandom.current().nextBytes(data);return data;}diff --git a/solr/test-framework/src/java/org/apache/solr/util/ServletFixtures.java b/solr/test-framework/src/java/org/apache/solr/util/ServletFixtures.javaindex 3405f34b6a2..b3551fa8a90 100644--- a/solr/test-framework/src/java/org/apache/solr/util/ServletFixtures.java+++ b/solr/test-framework/src/java/org/apache/solr/util/ServletFixtures.java@@ -154,7 +154,6 @@ public class ServletFixtures {}private void setCookies(HttpServletRequest req) {- Cookie[] ck = req.getCookies();cookies = req.getCookies();}diff --git a/solr/test-framework/src/java/org/apache/solr/util/SocketProxy.java b/solr/test-framework/src/java/org/apache/solr/util/SocketProxy.javaindex fed9355847f..2e0c6ea388b 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SocketProxy.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SocketProxy.java@@ -78,14 +78,13 @@ public class SocketProxy {}public SocketProxy(int port, boolean useSSL) throws Exception {- int listenPort = port;this.usesSSL = useSSL;serverSocket = createServerSocket(useSSL);serverSocket.setReuseAddress(true);if (receiveBufferSize > 0) {serverSocket.setReceiveBufferSize(receiveBufferSize);}- serverSocket.bind(new InetSocketAddress(listenPort), acceptBacklog);+ serverSocket.bind(new InetSocketAddress(port), acceptBacklog);this.listenPort = serverSocket.getLocalPort();}diff --git a/solr/test-framework/src/java/org/apache/solr/util/SolrClientTestRule.java b/solr/test-framework/src/java/org/apache/solr/util/SolrClientTestRule.javaindex cb2d74ff204..653c165b16c 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SolrClientTestRule.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SolrClientTestRule.java@@ -44,7 +44,7 @@ public abstract class SolrClientTestRule extends ExternalResource {/*** Starts the Solr server with the given solrHome. If solrHome contains a solr.xml file, it is- * used. Otherwise a default testing configuration is used.+ * used. Otherwise, a default testing configuration is used.*/public abstract void startSolr(Path solrHome);diff --git a/solr/test-framework/src/java/org/apache/solr/util/SolrMetricTestUtils.java b/solr/test-framework/src/java/org/apache/solr/util/SolrMetricTestUtils.javaindex a201c9227bd..5b4afc579a2 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SolrMetricTestUtils.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SolrMetricTestUtils.java@@ -40,24 +40,13 @@ import org.apache.solr.metrics.SolrMetricsContext;public final class SolrMetricTestUtils {private static final int MAX_ITERATIONS = 100;- private static final SolrInfoBean.Category CATEGORIES[] = SolrInfoBean.Category.values();+ private static final SolrInfoBean.Category[] CATEGORIES = SolrInfoBean.Category.values();// Cache name constantspublic static final String QUERY_RESULT_CACHE = "queryResultCache";public static final String FILTER_CACHE = "filterCache";- public static final String DOCUMENT_CACHE = "documentCache";public static final String PER_SEG_FILTER_CACHE = "perSegFilter";- public static String getRandomScope(Random random) {- return getRandomScope(random, random.nextBoolean());- }-- public static String getRandomScope(Random random, boolean shouldDefineScope) {- return shouldDefineScope- ? TestUtil.randomSimpleString(random, 5, 10)- : null; // must be simple string for JMX publishing- }-public static SolrInfoBean.Category getRandomCategory(Random random) {return CATEGORIES[TestUtil.nextInt(random, 0, CATEGORIES.length - 1)];}@@ -88,7 +77,7 @@ public final class SolrMetricTestUtils {/*** Looks up the first {@link MetricSnapshot} named {@code metricName}, and returns the first* {@link DataPointSnapshot} having exactly these {@code labels}. Null if not found. The result is- * typically casted to something useful.+ * typically cast to something useful.*/public static DataPointSnapshot getDataPointSnapshot(PrometheusMetricReader reader, String metricName, Labels labels) {diff --git a/solr/test-framework/src/java/org/apache/solr/util/SolrTestNonSecureRandomProvider.java b/solr/test-framework/src/java/org/apache/solr/util/SolrTestNonSecureRandomProvider.javaindex ac9eed8b946..5aef6bf2fb5 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SolrTestNonSecureRandomProvider.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SolrTestNonSecureRandomProvider.java@@ -49,7 +49,7 @@ public class SolrTestNonSecureRandomProvider extends Provider {// Assert that new SecureRandom() and// SecureRandom.getInstance("SHA1PRNG") return a SecureRandom backed- // by our non secure test provider.+ // by our non-secure test provider.SecureRandom rng1 = new SecureRandom();if (!SolrTestNonSecureRandomProvider.class.equals(rng1.getProvider().getClass())) {throw new SecurityException(diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.javaindex de02f1b2ccf..b05da370d4d 100644--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java@@ -77,14 +77,6 @@ public class TestHarness extends BaseTestHarness {}}- /**- * Creates a SolrConfig object for the default test core using {@link- * #createConfig(Path,String,String)}- */- public static SolrConfig createConfig(Path solrHome, String confFile) {- return createConfig(solrHome, SolrTestCaseJ4.DEFAULT_TEST_CORENAME, confFile);- }-public TestHarness(CoreContainer coreContainer) {this.container = coreContainer;this.coreName = SolrTestCaseJ4.DEFAULT_TEST_CORENAME;@@ -124,7 +116,7 @@ public class TestHarness extends BaseTestHarness {}/**- * Helper method to let us do some home sys prop check in delegated construtor. in "real" code+ * Helper method to let us do some home sys prop check in delegated constructor. in "real" code* SolrDispatchFilter takes care of checking this sys prop when building NodeConfig/CoreContainer*/private static Path checkAndReturnSolrHomeSysProp() {@@ -421,7 +413,7 @@ public class TestHarness extends BaseTestHarness {* the "qtype", "start", "limit", and "args" properties of this factory are ignored.</b>* </ul>*- * TODO: this isn't really safe in the presense of core reloads! Perhaps the best we could do is+ * TODO: this isn't really safe in the presence of core reloads! Perhaps the best we could do is* increment the core reference count and decrement it in the request close() method?*/@SuppressWarnings({"unchecked"})diff --git a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/SolrPortAwareCookieSpecTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/SolrPortAwareCookieSpecTest.javaindex 73b1536a3c5..b88ce8faee0 100644--- a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/SolrPortAwareCookieSpecTest.java+++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/SolrPortAwareCookieSpecTest.java@@ -40,7 +40,7 @@ public class SolrPortAwareCookieSpecTest extends SolrTestCaseJ4 {}@Test- public void testDomainHostPortMatch() throws Exception {+ public void testDomainHostPortMatch() {final BasicClientCookie cookie = new BasicClientCookie("name", "value");final CookieOrigin origin = new CookieOrigin("myhost", 80, "/", false);final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();@@ -120,7 +120,7 @@ public class SolrPortAwareCookieSpecTest extends SolrTestCaseJ4 {}@Test- public void testDomainMatch1() throws Exception {+ public void testDomainMatch1() {final BasicClientCookie cookie = new BasicClientCookie("name", "value");final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();@@ -133,7 +133,7 @@ public class SolrPortAwareCookieSpecTest extends SolrTestCaseJ4 {}@Test- public void testDomainMatch2() throws Exception {+ public void testDomainMatch2() {final BasicClientCookie cookie = new BasicClientCookie("name", "value");final CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();@@ -143,7 +143,7 @@ public class SolrPortAwareCookieSpecTest extends SolrTestCaseJ4 {}@Test- public void testDomainInvalidInput() throws Exception {+ public void testDomainInvalidInput() {final CookieAttributeHandler h = new SolrPortAwareCookieSpecFactory.PortAwareDomainHandler();SolrTestCaseJ4.expectThrows(IllegalArgumentException.class, () -> h.match(null, null));SolrTestCaseJ4.expectThrows(diff --git a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.javaindex 8c8243e172c..0d17dc41d92 100644--- a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java+++ b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java@@ -190,7 +190,8 @@ public class MiniSolrCloudClusterTest extends SolrTestCaseJ4 {public void testJettyUsingSysProp() throws Exception {try {- // this cluster will use a sysprop to communicate zkHost to it's nodes -- not node props in+ // this cluster will use a system property to communicate zkHost to its nodes -- not node+ // props in// the servlet contextfinal MiniSolrCloudCluster x =new MiniSolrCloudCluster(1, createTempDir(), JettyConfig.builder().build()) {@@ -234,6 +235,6 @@ public class MiniSolrCloudClusterTest extends SolrTestCaseJ4 {private static void assertZkHost(final String msg, final String zkHost, final JettySolrRunner node) {- assertEquals(zkHost, node.getCoreContainer().getNodeConfig().getCloudConfig().getZkHost());+ assertEquals(msg, zkHost, node.getCoreContainer().getNodeConfig().getCloudConfig().getZkHost());}}diff --git a/solr/test-framework/src/test/org/apache/solr/util/TestErrorLogMuter.java b/solr/test-framework/src/test/org/apache/solr/util/TestErrorLogMuter.javaindex 976a75c4462..452bc7e3d1c 100644--- a/solr/test-framework/src/test/org/apache/solr/util/TestErrorLogMuter.java+++ b/solr/test-framework/src/test/org/apache/solr/util/TestErrorLogMuter.java@@ -33,7 +33,7 @@ public class TestErrorLogMuter extends SolrTestCaseJ4 {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());@LogLevel("=WARN")- public void testErrorMutingRegex() throws Exception {+ public void testErrorMutingRegex() {try (LogListener rootWarnCheck = LogListener.warn("");LogListener rootErrorCheck = LogListener.error("")) {@@ -54,7 +54,7 @@ public class TestErrorLogMuter extends SolrTestCaseJ4 {log.error("This {} because of the {} msg","error",- "thowable",+ "throwable",new Exception("outer", new Exception("inner eRrOr Log throwable")));assertEquals(2, x.getCount());}@@ -66,7 +66,7 @@ public class TestErrorLogMuter extends SolrTestCaseJ4 {}@LogLevel("=WARN")- public void testMultipleMuters() throws Exception {+ public void testMultipleMuters() {try (LogListener rootWarnCheck = LogListener.warn("").substring("xxx");LogListener rootErrorCheck = LogListener.error("")) {@@ -88,7 +88,7 @@ public class TestErrorLogMuter extends SolrTestCaseJ4 {// a warning shouldn't be muted...log.warn("xxx yyy");- assertEquals(rootWarnCheck.pollMessage(), "xxx yyy");+ assertEquals("xxx yyy", rootWarnCheck.pollMessage());log.error("abc", new Exception("yyy"));@@ -104,7 +104,7 @@ public class TestErrorLogMuter extends SolrTestCaseJ4 {}@LogLevel("=WARN")- public void testDeprecatedBaseClassMethods() throws Exception {+ public void testDeprecatedBaseClassMethods() {// NOTE: using the same queue for both interceptors (mainly as proof that you can)try (LogListener rootWarnCheck = LogListener.warn("");diff --git a/solr/test-framework/src/test/org/apache/solr/util/TestLogLevelAnnotations.java b/solr/test-framework/src/test/org/apache/solr/util/TestLogLevelAnnotations.javaindex ebfad4ea63c..06c708957c3 100644--- a/solr/test-framework/src/test/org/apache/solr/util/TestLogLevelAnnotations.java+++ b/solr/test-framework/src/test/org/apache/solr/util/TestLogLevelAnnotations.java@@ -51,7 +51,7 @@ public class TestLogLevelAnnotations extends SolrTestCase {* modifying the log4j run time configuration. The <code>@LogLevel</code> configuration of this* class <em>should</em> not affect the "root" Logger, but setting this in static class* initialization protect us (as best we can) against the possibility that it <em>might</em> due- * to an unforseen (future) bug.+ * to an unforeseen (future) bug.** @see #checkLogLevelsBeforeClass*/