From 07a203628ea46308612f4bb60686c313a6e4d75e Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Wed, 10 Jun 2020 18:05:50 -0400 Subject: [PATCH] SOLR-14455: Fix or suppress warnings in solr/test-framework --- solr/CHANGES.txt | 4 +- .../solr/BaseDistributedSearchTestCase.java | 18 +++++-- .../java/org/apache/solr/JSONTestUtil.java | 7 +++ .../java/org/apache/solr/SolrTestCaseHS.java | 10 +++- .../java/org/apache/solr/SolrTestCaseJ4.java | 48 +++++++++++++++++-- .../cloud/AbstractFullDistribZkTestBase.java | 8 +++- .../apache/solr/cloud/CloudInspectUtil.java | 17 +++++-- .../org/apache/solr/cloud/ConfigRequest.java | 1 + .../solr/cloud/SolrCloudAuthTestCase.java | 4 ++ .../apache/solr/cloud/SolrCloudTestCase.java | 3 ++ .../solr/core/MockTracerConfigurator.java | 2 +- .../org/apache/solr/util/RandomizeSSL.java | 4 +- .../org/apache/solr/util/TestHarness.java | 5 +- 13 files changed, 111 insertions(+), 20 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8182f82d214..80c467ab135 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -325,7 +325,9 @@ Other Changes * SOLR-14548: Address warning: static member should be qualified by type name (Mike Drob) -* SOLR-14547: Fix or suppress warnings in solr/client/solrj/io/stream +* SOLR-14547: Fix or suppress warnings in solr/client/solrj/io/stream (Erick Erickson) + +* SOLR-14455: Fix or suppress warnings in solr/test-framework (Erick Erickson) ================== 8.5.2 ================== diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java index 867e7300a56..66c1974a726 100644 --- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java @@ -737,17 +737,21 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { return f == null ? 0 : f; } - public static String compare(NamedList a, NamedList b, int flags, Map handle) { + @SuppressWarnings({"unchecked"}) + public static String compare(@SuppressWarnings({"rawtypes"})NamedList a, + @SuppressWarnings({"rawtypes"})NamedList b, int flags, Map handle) { // System.out.println("resp a:" + a); // System.out.println("resp b:" + b); boolean ordered = (flags & UNORDERED) == 0; if (!ordered) { + @SuppressWarnings({"rawtypes"}) Map mapA = new HashMap(a.size()); for (int i=0; i handle) { + public static String compare1(@SuppressWarnings({"rawtypes"})Map a, + @SuppressWarnings({"rawtypes"})Map b, + int flags, Map handle) { String cmp; for (Object keya : a.keySet()) { @@ -832,7 +838,9 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { return null; } - public static String compare(Map a, Map b, int flags, Map handle) { + public static String compare(@SuppressWarnings({"rawtypes"})Map a, + @SuppressWarnings({"rawtypes"})Map b, + int flags, Map handle) { String cmp; cmp = compare1(a, b, flags, handle); if (cmp != null) return cmp; @@ -1071,6 +1079,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { } @Override + @SuppressWarnings({"rawtypes"}) public void callStatement() throws Throwable { RandVal.uniqueValues = new HashSet(); // reset random values fixShardCount(numShards); @@ -1098,6 +1107,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { } @Override + @SuppressWarnings({"rawtypes"}) public void callStatement() throws Throwable { for (shardCount = min; shardCount <= max; shardCount++) { @@ -1155,7 +1165,9 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { /* no-op */ } + @SuppressWarnings({"unchecked"}) public static abstract class RandVal { + @SuppressWarnings({"rawtypes"}) public static Set uniqueValues = new HashSet(); public abstract Object val(); diff --git a/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java b/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java index f5b2ffb45f7..b1acca823a2 100644 --- a/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java +++ b/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java @@ -105,6 +105,7 @@ public class JSONTestUtil { @Override public void addKeyVal(Object map, Object key, Object val) throws IOException { + @SuppressWarnings({"unchecked"}) Object prev = ((Map) map).put(key, val); if (prev != null) { throw new RuntimeException("REPEATED JSON OBJECT KEY: key=" + key + " prevValue=" + prev + " thisValue" + val); @@ -259,7 +260,9 @@ class CollectionTester { } boolean matchList() { + @SuppressWarnings({"rawtypes"}) List expectedList = (List)expected; + @SuppressWarnings({"rawtypes"}) List v = asList(); if (v == null) return false; int a = 0; @@ -290,6 +293,7 @@ class CollectionTester { private static Set reserved = new HashSet<>(Arrays.asList("_SKIP_","_MATCH_","_ORDERED_","_UNORDERED_")); + @SuppressWarnings({"unchecked", "rawtypes"}) boolean matchMap() { Map expectedMap = (Map)expected; Map v = asMap(); @@ -397,6 +401,7 @@ class CollectionTester { return seek(pathList); } + @SuppressWarnings({"rawtypes"}) List asList() { // TODO: handle native arrays if (val instanceof List) { @@ -406,6 +411,7 @@ class CollectionTester { return null; } + @SuppressWarnings({"unchecked"}) Map asMap() { // TODO: handle NamedList if (val instanceof Map) { @@ -420,6 +426,7 @@ class CollectionTester { String seg = seekPath.get(0); if (seg.charAt(0)=='[') { + @SuppressWarnings({"rawtypes"}) List listVal = asList(); if (listVal==null) return false; diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java index cc572a962b8..919a1c914f8 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java @@ -81,6 +81,7 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 { return s; } + @SuppressWarnings({"unchecked"}) public static T rand(T... vals) { return vals[ random().nextInt(vals.length) ]; } @@ -109,9 +110,13 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 { } - public static Object createDocObjects(Map fullModel, Comparator sort, int rows, Collection fieldNames) { + @SuppressWarnings({"unchecked"}) + public static Object createDocObjects(@SuppressWarnings({"rawtypes"})Map fullModel, + @SuppressWarnings({"rawtypes"})Comparator sort, int rows, + Collection fieldNames) { List docList = new ArrayList<>(fullModel.values()); Collections.sort(docList, sort); + @SuppressWarnings({"rawtypes"}) List sortedDocs = new ArrayList(rows); for (Doc doc : docList) { if (sortedDocs.size() >= rows) break; @@ -122,7 +127,8 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 { } - public static void compare(SolrQueryRequest req, String path, Object model, Map fullModel) throws Exception { + public static void compare(SolrQueryRequest req, String path, Object model, + @SuppressWarnings({"rawtypes"})Map fullModel) throws Exception { String strResponse = h.query(req); Object realResponse = ObjectBuilder.fromJSON(strResponse); diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index 10317836d3d..d70013be349 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -446,7 +446,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { private static Map savedClassLogLevels = new HashMap<>(); public static void initClassLogLevels() { + @SuppressWarnings({"rawtypes"}) Class currentClass = RandomizedContext.current().getTargetClass(); + @SuppressWarnings({"unchecked"}) LogLevel annotation = (LogLevel) currentClass.getAnnotation(LogLevel.class); if (annotation == null) { return; @@ -1292,6 +1294,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { return msp; } + @SuppressWarnings({"unchecked", "rawtypes"}) public static Map map(Object... params) { LinkedHashMap ret = new LinkedHashMap(); for (int i=0; iout array with JSON from the doc. * Doesn't currently handle boosts, but does recursively handle child documents */ + @SuppressWarnings({"unchecked"}) public static void json(SolrInputDocument doc, CharArr out) { try { out.append('{'); @@ -1576,7 +1580,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { params = mparams; } String response = updateJ(jsonAdd(sdoc), params); + @SuppressWarnings({"rawtypes"}) Map rsp = (Map)ObjectBuilder.fromJSON(response); + @SuppressWarnings({"rawtypes"}) List lst = (List)rsp.get("adds"); if (lst == null || lst.size() == 0) return null; return (Long) lst.get(1); @@ -1589,7 +1595,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { params = mparams; } String response = updateJ(jsonDelId(id), params); + @SuppressWarnings({"rawtypes"}) Map rsp = (Map)ObjectBuilder.fromJSON(response); + @SuppressWarnings({"rawtypes"}) List lst = (List)rsp.get("deletes"); if (lst == null || lst.size() == 0) return null; return (Long) lst.get(1); @@ -1602,7 +1610,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { params = mparams; } String response = updateJ(jsonDelQ(q), params); + @SuppressWarnings({"rawtypes"}) Map rsp = (Map)ObjectBuilder.fromJSON(response); + @SuppressWarnings({"rawtypes"}) List lst = (List)rsp.get("deleteByQuery"); if (lst == null || lst.size() == 0) return null; return (Long) lst.get(1); @@ -1613,8 +1623,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { ///////////////////////////////////////////////////////////////////////////////////// public abstract static class Vals { + @SuppressWarnings({"rawtypes"}) public abstract Comparable get(); - public String toJSON(Comparable val) { + public String toJSON(@SuppressWarnings({"rawtypes"})Comparable val) { return JSONUtil.toJSON(val); } @@ -1641,6 +1652,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"rawtypes"}) public Comparable get() { return getInt(); } @@ -1667,6 +1679,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"rawtypes"}) public Comparable get() { return getInt(); } @@ -1686,6 +1699,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"rawtypes"}) public Comparable get() { return getFloat(); } @@ -1694,6 +1708,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { public static class BVal extends Vals { @Override + @SuppressWarnings({"rawtypes"}) public Comparable get() { return random().nextBoolean(); } @@ -1717,6 +1732,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"rawtypes"}) public Comparable get() { char[] arr = new char[between(minLength,maxLength)]; for (int i=0; i fields; @@ -1754,12 +1771,14 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"unchecked"}) public int compareTo(Object o) { if (!(o instanceof Doc)) return this.getClass().hashCode() - o.getClass().hashCode(); Doc other = (Doc)o; return this.id.compareTo(other.id); } + @SuppressWarnings({"rawtypes"}) public List getValues(String field) { for (Fld fld : fields) { if (fld.ftype.fname.equals(field)) return fld.vals; @@ -1767,6 +1786,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { return null; } + @SuppressWarnings({"rawtypes"}) public Comparable getFirstValue(String field) { List vals = getValues(field); return vals==null || vals.size()==0 ? null : vals.get(0); @@ -1789,6 +1809,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { public static class Fld { public FldType ftype; + @SuppressWarnings({"rawtypes"}) public List vals; @Override public String toString() { @@ -1811,10 +1832,12 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { this.vals = vals; } + @SuppressWarnings({"rawtypes"}) public Comparable createValue() { return vals.get(); } + @SuppressWarnings({"rawtypes"}) public List createValues() { int nVals = numValues.getInt(); if (nVals <= 0) return null; @@ -1825,6 +1848,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } public Fld createField() { + @SuppressWarnings({"rawtypes"}) List vals = createValues(); if (vals == null) return null; @@ -1846,6 +1870,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } }); } + @SuppressWarnings({"rawtypes"}) public Map indexDocs(List descriptor, Map model, int nDocs) throws Exception { if (model == null) { model = new LinkedHashMap<>(); @@ -1890,6 +1915,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { response = ((Map)response).get("response"); response = ((Map)response).get("docs"); + @SuppressWarnings({"unchecked"}) List docList = (List)response; int order = 0; for (Map doc : docList) { @@ -1966,6 +1992,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } return new Comparator() { + @SuppressWarnings({"rawtypes"}) private Comparable zeroVal(Comparable template) { if (template == null) return null; if (template instanceof String) return null; // fast-path for string @@ -1980,8 +2007,11 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } @Override + @SuppressWarnings({"unchecked"}) public int compare(Doc o1, Doc o2) { + @SuppressWarnings({"rawtypes"}) Comparable v1 = o1.getFirstValue(field); + @SuppressWarnings({"rawtypes"}) Comparable v2 = o2.getFirstValue(field); v1 = v1 == null ? zeroVal(v2) : v1; @@ -2035,7 +2065,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { out.append('['); } boolean firstVal = true; - for (Comparable val : fld.vals) { + for (@SuppressWarnings({"rawtypes"})Comparable val : fld.vals) { if (firstVal) firstVal=false; else out.append(','); out.append(JSONUtil.toJSON(val)); @@ -2052,6 +2082,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } /** Return a Map from field value to a list of document ids */ + @SuppressWarnings({"rawtypes"}) public Map> invertField(Map model, String field) { Map> value_to_id = new HashMap<>(); @@ -2344,12 +2375,16 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { if (!(sdoc2.get(key2).getFirstValue() instanceof SolrInputDocument)) { return false; } + @SuppressWarnings({"rawtypes"}) Collection col1 = (Collection) val1; + @SuppressWarnings({"rawtypes"}) Collection col2 = (Collection) val2; if (col1.size() != col2.size()) { return false; } + @SuppressWarnings({"unchecked"}) Iterator colIter1 = col1.iterator(); + @SuppressWarnings({"unchecked"}) Iterator colIter2 = col2.iterator(); while (colIter1.hasNext()) { if (!compareSolrInputDocument(colIter1.next(), colIter2.next())) { @@ -2552,7 +2587,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } public static CloudSolrClientBuilder newCloudSolrClient(String zkHost) { - return (CloudSolrClientBuilder) new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()); + return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()); } /** @@ -2916,6 +2951,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { System.clearProperty(SYSTEM_PROPERTY_SOLR_DISABLE_SHARDS_WHITELIST); } + @SuppressWarnings({"unchecked"}) protected T pickRandom(T... options) { return options[random().nextInt(options.length)]; } @@ -2980,6 +3016,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { * @lucene.experimental * @lucene.internal */ + @SuppressWarnings({"rawtypes"}) private static void randomizeNumericTypesProperties() { final boolean useDV = random().nextBoolean(); @@ -3043,7 +3080,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { org.apache.solr.schema.PointField.TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGS = false; System.clearProperty("solr.tests.numeric.points"); System.clearProperty("solr.tests.numeric.points.dv"); - for (Class c : RANDOMIZED_NUMERIC_FIELDTYPES.keySet()) { + for (@SuppressWarnings({"rawtypes"})Class c : RANDOMIZED_NUMERIC_FIELDTYPES.keySet()) { System.clearProperty("solr.tests." + c.getSimpleName() + "FieldType"); } private_RANDOMIZED_NUMERIC_FIELDTYPES.clear(); @@ -3059,6 +3096,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { private static boolean isChildDoc(Object o) { if(o instanceof Collection) { + @SuppressWarnings({"rawtypes"}) Collection col = (Collection) o; if(col.size() == 0) { return false; @@ -3068,6 +3106,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { return o instanceof SolrInputDocument; } + @SuppressWarnings({"rawtypes"}) private static final Map private_RANDOMIZED_NUMERIC_FIELDTYPES = new HashMap<>(); /** @@ -3079,6 +3118,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { * * @see #randomizeNumericTypesProperties */ + @SuppressWarnings({"rawtypes"}) protected static final Map RANDOMIZED_NUMERIC_FIELDTYPES = Collections.unmodifiableMap(private_RANDOMIZED_NUMERIC_FIELDTYPES); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index 512cae58b77..2160681bc09 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 @@ -386,7 +386,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes protected List createJettys(int numJettys) throws Exception { List jettys = Collections.synchronizedList(new ArrayList<>()); List clients = Collections.synchronizedList(new ArrayList<>()); + @SuppressWarnings({"rawtypes"}) List createReplicaRequests = Collections.synchronizedList(new ArrayList<>()); + @SuppressWarnings({"rawtypes"}) List createPullReplicaRequests = Collections.synchronizedList(new ArrayList<>()); StringBuilder sb = new StringBuilder(); @@ -522,7 +524,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes customThreadPool = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createReplicaRequests")); - for (CollectionAdminRequest r : createReplicaRequests) { + for (@SuppressWarnings({"rawtypes"})CollectionAdminRequest r : createReplicaRequests) { customThreadPool.submit(() -> { CollectionAdminResponse response; try { @@ -540,7 +542,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes customThreadPool = ExecutorUtil .newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createPullReplicaRequests")); - for (CollectionAdminRequest r : createPullReplicaRequests) { + for (@SuppressWarnings({"rawtypes"})CollectionAdminRequest r : createPullReplicaRequests) { customThreadPool.submit(() -> { CollectionAdminResponse response; try { @@ -1801,6 +1803,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes collectionInfos.put(collectionName, list); } params.set("name", collectionName); + @SuppressWarnings({"rawtypes"}) SolrRequest request = new QueryRequest(params); request.setPath("/admin/collections"); @@ -2403,6 +2406,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes static RequestStatusState getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException { CollectionAdminResponse response = getStatusResponse(requestId, client); + @SuppressWarnings({"rawtypes"}) NamedList innerResponse = (NamedList) response.getResponse().get("status"); return RequestStatusState.fromKey((String) innerResponse.get("state")); } 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.java index 499f0279cf6..bc3b1086e86 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 @@ -48,23 +48,28 @@ public class CloudInspectUtil { * @param bDeleteFails null or list of the ids of deletes that failed for b * @return true if the difference in a and b is legal */ + @SuppressWarnings({"unchecked"}) public static boolean checkIfDiffIsLegal(SolrDocumentList a, SolrDocumentList b, String aName, String bName, Set bAddFails, Set bDeleteFails) { boolean legal = true; + @SuppressWarnings({"rawtypes"}) Set setA = new HashSet<>(); for (SolrDocument sdoc : a) { - setA.add(new HashMap(sdoc)); + setA.add(new HashMap<>(sdoc)); } + @SuppressWarnings({"rawtypes"}) Set setB = new HashSet<>(); for (SolrDocument sdoc : b) { - setB.add(new HashMap(sdoc)); + setB.add(new HashMap<>(sdoc)); } + @SuppressWarnings({"rawtypes"}) Set onlyInA = new HashSet<>(setA); onlyInA.removeAll(setB); + @SuppressWarnings({"rawtypes"}) Set onlyInB = new HashSet<>(setB); onlyInB.removeAll(setA); @@ -75,7 +80,7 @@ public class CloudInspectUtil { System.err.println("###### Only in " + aName + ": " + onlyInA); System.err.println("###### Only in " + bName + ": " + onlyInB); - for (Map doc : onlyInA) { + for (@SuppressWarnings({"rawtypes"})Map doc : onlyInA) { if (bAddFails == null || !bAddFails.contains(doc.get("id"))) { legal = false; // System.err.println("###### Only in " + aName + ": " + doc.get("id")); @@ -86,7 +91,7 @@ public class CloudInspectUtil { } } - for (Map doc : onlyInB) { + for (@SuppressWarnings({"rawtypes"})Map doc : onlyInB) { if (bDeleteFails == null || !bDeleteFails.contains(doc.get("id"))) { legal = false; // System.err.println("###### Only in " + bName + ": " + doc.get("id")); @@ -109,6 +114,7 @@ public class CloudInspectUtil { * @param bName label for the second list * @return the documents only in list a */ + @SuppressWarnings({"unchecked", "rawtypes"}) public static Set showDiff(SolrDocumentList a, SolrDocumentList b, String aName, String bName) { System.err.println("######" + aName + ": " + toStr(a, 10)); @@ -203,6 +209,7 @@ public class CloudInspectUtil { } } + @SuppressWarnings({"rawtypes"}) Set differences = CloudInspectUtil.showDiff(controlDocList, cloudDocList, "controlDocList", "cloudDocList"); @@ -213,7 +220,7 @@ public class CloudInspectUtil { // use filter() to allow being parsed as 'terms in set' query instead of a (weighted/scored) // BooleanQuery so we don't trip too many boolean clauses StringBuilder ids = new StringBuilder("filter(id:("); - for (Map doc : differences) { + for (@SuppressWarnings({"rawtypes"})Map doc : differences) { ids.append(" ").append(doc.get("id")); foundId = true; } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ConfigRequest.java b/solr/test-framework/src/java/org/apache/solr/cloud/ConfigRequest.java index 12b5a37df56..6b4c61770d0 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/ConfigRequest.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/ConfigRequest.java @@ -29,6 +29,7 @@ import org.apache.solr.common.params.SolrParams; * e.g. to add custom components, handlers, parsers, etc. to an otherwise * generic configset. */ +@SuppressWarnings({"rawtypes"}) public class ConfigRequest extends SolrRequest { protected final String message; 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.java index 9485c80a438..2d23857e4a7 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 @@ -64,6 +64,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase { private static final List AUTH_METRICS_TIMER_KEYS = Collections.singletonList("requestTimes"); private static final String METRICS_PREFIX_PKI = "SECURITY./authentication/pki."; private static final String METRICS_PREFIX = "SECURITY./authentication."; + @SuppressWarnings({"rawtypes"}) public static final Predicate NOT_NULL_PREDICATE = o -> o != null; private static final List AUDIT_METRICS_KEYS = Arrays.asList("count"); private static final List AUTH_METRICS_TO_COMPARE = Arrays.asList("requests", "authenticated", "passThrough", "failWrongCredentials", "failMissingCredentials", "errors"); @@ -188,6 +189,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase { } + @SuppressWarnings({"unchecked"}) private static void verifySecurityStatus(HttpClient cl, String url, String objPath, Object expected, int count, String authHeader) throws IOException, InterruptedException { boolean success = false; @@ -198,6 +200,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase { if (authHeader != null) setAuthorizationHeader(get, authHeader); HttpResponse rsp = cl.execute(get); s = EntityUtils.toString(rsp.getEntity()); + @SuppressWarnings({"rawtypes"}) Map m = null; try { m = (Map) Utils.fromJSONString(s); @@ -207,6 +210,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase { Utils.consumeFully(rsp.getEntity()); Object actual = Utils.getObjectByPath(m, true, hierarchy); if (expected instanceof Predicate) { + @SuppressWarnings({"rawtypes"}) Predicate predicate = (Predicate) expected; if (predicate.test(actual)) { success = true; diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java index 9c34fac9de3..b646e2e82f6 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 @@ -234,11 +234,13 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 { } public Builder withDefaultClusterProperty(String key, String value) { + @SuppressWarnings({"unchecked"}) HashMap defaults = (HashMap) this.clusterProperties.get(CollectionAdminParams.DEFAULTS); if (defaults == null) { defaults = new HashMap<>(); this.clusterProperties.put(CollectionAdminParams.DEFAULTS, defaults); } + @SuppressWarnings({"unchecked"}) HashMap cluster = (HashMap) defaults.get(CollectionAdminParams.CLUSTER); if (cluster == null) { cluster = new HashMap<>(); @@ -447,6 +449,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 { } } + @SuppressWarnings({"rawtypes"}) protected NamedList waitForResponse(Predicate predicate, SolrRequest request, int intervalInMillis, int numRetries, String messageOnFail) { log.info("waitForResponse: {}", request); int i = 0; diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java b/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java index fd02bda7efe..b1c7cb9168d 100644 --- a/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java +++ b/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java @@ -29,7 +29,7 @@ public class MockTracerConfigurator extends TracerConfigurator { } @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { } } diff --git a/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java b/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java index 2450dadc2df..20644a38a46 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 @@ -135,8 +135,9 @@ public @interface RandomizeSSL { /** * Returns an SSLRandomizer suitable for the specified (test) class */ - public static final SSLRandomizer getSSLRandomizerForClass(Class clazz) { + public static final SSLRandomizer getSSLRandomizerForClass(@SuppressWarnings({"rawtypes"})Class clazz) { + @SuppressWarnings({"unchecked"}) final SuppressSSL suppression = (SuppressSSL) clazz.getAnnotation(SuppressSSL.class); if (null != suppression) { // Even if this class has a RandomizeSSL annotation, any usage of SuppressSSL -- even in a @@ -147,6 +148,7 @@ public @interface RandomizeSSL { return new SSLRandomizer(0.0D, 0.0D, suppression.toString()); } + @SuppressWarnings({"unchecked"}) final RandomizeSSL annotation = (RandomizeSSL) clazz.getAnnotation(RandomizeSSL.class); if (null == annotation) { 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.java index 3044d139068..5814ad42fda 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 @@ -274,7 +274,7 @@ public class TestHarness extends BaseTestHarness { } return connection.request(handler, null, xml); } catch (SolrException e) { - throw (SolrException)e; + throw e; } catch (Exception e) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } @@ -436,6 +436,7 @@ public class TestHarness extends BaseTestHarness { * Perhaps the best we could do is increment the core reference count * and decrement it in the request close() method? */ + @SuppressWarnings({"unchecked"}) public LocalSolrQueryRequest makeRequest(String ... q) { if (q.length==1) { return new LocalSolrQueryRequest(TestHarness.this.getCore(), @@ -444,10 +445,12 @@ public class TestHarness extends BaseTestHarness { if (q.length%2 != 0) { throw new RuntimeException("The length of the string array (query arguments) needs to be even"); } + @SuppressWarnings({"rawtypes"}) Map.Entry [] entries = new NamedListEntry[q.length / 2]; for (int i = 0; i < q.length; i += 2) { entries[i/2] = new NamedListEntry<>(q[i], q[i+1]); } + @SuppressWarnings({"rawtypes"}) NamedList nl = new NamedList(entries); if(nl.get("wt" ) == null) nl.add("wt","xml"); return new LocalSolrQueryRequest(TestHarness.this.getCore(), nl);