SOLR-14455: Fix or suppress warnings in solr/test-framework

This commit is contained in:
Erick Erickson 2020-06-10 18:05:50 -04:00
parent 9728f4ef20
commit 07a203628e
13 changed files with 111 additions and 20 deletions

View File

@ -325,7 +325,9 @@ Other Changes
* SOLR-14548: Address warning: static member should be qualified by type name (Mike Drob) * 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 ================== ================== 8.5.2 ==================

View File

@ -737,17 +737,21 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
return f == null ? 0 : f; return f == null ? 0 : f;
} }
public static String compare(NamedList a, NamedList b, int flags, Map<String, Integer> handle) { @SuppressWarnings({"unchecked"})
public static String compare(@SuppressWarnings({"rawtypes"})NamedList a,
@SuppressWarnings({"rawtypes"})NamedList b, int flags, Map<String, Integer> handle) {
// System.out.println("resp a:" + a); // System.out.println("resp a:" + a);
// System.out.println("resp b:" + b); // System.out.println("resp b:" + b);
boolean ordered = (flags & UNORDERED) == 0; boolean ordered = (flags & UNORDERED) == 0;
if (!ordered) { if (!ordered) {
@SuppressWarnings({"rawtypes"})
Map mapA = new HashMap(a.size()); Map mapA = new HashMap(a.size());
for (int i=0; i<a.size(); i++) { for (int i=0; i<a.size(); i++) {
Object prev = mapA.put(a.getName(i), a.getVal(i)); Object prev = mapA.put(a.getName(i), a.getVal(i));
} }
@SuppressWarnings({"rawtypes"})
Map mapB = new HashMap(b.size()); Map mapB = new HashMap(b.size());
for (int i=0; i<b.size(); i++) { for (int i=0; i<b.size(); i++) {
Object prev = mapB.put(b.getName(i), b.getVal(i)); Object prev = mapB.put(b.getName(i), b.getVal(i));
@ -814,7 +818,9 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
return null; return null;
} }
public static String compare1(Map a, Map b, int flags, Map<String, Integer> handle) { public static String compare1(@SuppressWarnings({"rawtypes"})Map a,
@SuppressWarnings({"rawtypes"})Map b,
int flags, Map<String, Integer> handle) {
String cmp; String cmp;
for (Object keya : a.keySet()) { for (Object keya : a.keySet()) {
@ -832,7 +838,9 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
return null; return null;
} }
public static String compare(Map a, Map b, int flags, Map<String, Integer> handle) { public static String compare(@SuppressWarnings({"rawtypes"})Map a,
@SuppressWarnings({"rawtypes"})Map b,
int flags, Map<String, Integer> handle) {
String cmp; String cmp;
cmp = compare1(a, b, flags, handle); cmp = compare1(a, b, flags, handle);
if (cmp != null) return cmp; if (cmp != null) return cmp;
@ -1071,6 +1079,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public void callStatement() throws Throwable { public void callStatement() throws Throwable {
RandVal.uniqueValues = new HashSet(); // reset random values RandVal.uniqueValues = new HashSet(); // reset random values
fixShardCount(numShards); fixShardCount(numShards);
@ -1098,6 +1107,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public void callStatement() throws Throwable { public void callStatement() throws Throwable {
for (shardCount = min; shardCount <= max; shardCount++) { for (shardCount = min; shardCount <= max; shardCount++) {
@ -1155,7 +1165,9 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
/* no-op */ /* no-op */
} }
@SuppressWarnings({"unchecked"})
public static abstract class RandVal { public static abstract class RandVal {
@SuppressWarnings({"rawtypes"})
public static Set uniqueValues = new HashSet(); public static Set uniqueValues = new HashSet();
public abstract Object val(); public abstract Object val();

View File

@ -105,6 +105,7 @@ public class JSONTestUtil {
@Override @Override
public void addKeyVal(Object map, Object key, Object val) throws IOException { public void addKeyVal(Object map, Object key, Object val) throws IOException {
@SuppressWarnings({"unchecked"})
Object prev = ((Map<Object, Object>) map).put(key, val); Object prev = ((Map<Object, Object>) map).put(key, val);
if (prev != null) { if (prev != null) {
throw new RuntimeException("REPEATED JSON OBJECT KEY: key=" + key + " prevValue=" + prev + " thisValue" + val); throw new RuntimeException("REPEATED JSON OBJECT KEY: key=" + key + " prevValue=" + prev + " thisValue" + val);
@ -259,7 +260,9 @@ class CollectionTester {
} }
boolean matchList() { boolean matchList() {
@SuppressWarnings({"rawtypes"})
List expectedList = (List)expected; List expectedList = (List)expected;
@SuppressWarnings({"rawtypes"})
List v = asList(); List v = asList();
if (v == null) return false; if (v == null) return false;
int a = 0; int a = 0;
@ -290,6 +293,7 @@ class CollectionTester {
private static Set<String> reserved = new HashSet<>(Arrays.asList("_SKIP_","_MATCH_","_ORDERED_","_UNORDERED_")); private static Set<String> reserved = new HashSet<>(Arrays.asList("_SKIP_","_MATCH_","_ORDERED_","_UNORDERED_"));
@SuppressWarnings({"unchecked", "rawtypes"})
boolean matchMap() { boolean matchMap() {
Map<String,Object> expectedMap = (Map<String,Object>)expected; Map<String,Object> expectedMap = (Map<String,Object>)expected;
Map<String,Object> v = asMap(); Map<String,Object> v = asMap();
@ -397,6 +401,7 @@ class CollectionTester {
return seek(pathList); return seek(pathList);
} }
@SuppressWarnings({"rawtypes"})
List asList() { List asList() {
// TODO: handle native arrays // TODO: handle native arrays
if (val instanceof List) { if (val instanceof List) {
@ -406,6 +411,7 @@ class CollectionTester {
return null; return null;
} }
@SuppressWarnings({"unchecked"})
Map<String,Object> asMap() { Map<String,Object> asMap() {
// TODO: handle NamedList // TODO: handle NamedList
if (val instanceof Map) { if (val instanceof Map) {
@ -420,6 +426,7 @@ class CollectionTester {
String seg = seekPath.get(0); String seg = seekPath.get(0);
if (seg.charAt(0)=='[') { if (seg.charAt(0)=='[') {
@SuppressWarnings({"rawtypes"})
List listVal = asList(); List listVal = asList();
if (listVal==null) return false; if (listVal==null) return false;

View File

@ -81,6 +81,7 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 {
return s; return s;
} }
@SuppressWarnings({"unchecked"})
public static <T> T rand(T... vals) { public static <T> T rand(T... vals) {
return vals[ random().nextInt(vals.length) ]; return vals[ random().nextInt(vals.length) ];
} }
@ -109,9 +110,13 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 {
} }
public static Object createDocObjects(Map<Comparable, Doc> fullModel, Comparator sort, int rows, Collection<String> fieldNames) { @SuppressWarnings({"unchecked"})
public static Object createDocObjects(@SuppressWarnings({"rawtypes"})Map<Comparable, Doc> fullModel,
@SuppressWarnings({"rawtypes"})Comparator sort, int rows,
Collection<String> fieldNames) {
List<Doc> docList = new ArrayList<>(fullModel.values()); List<Doc> docList = new ArrayList<>(fullModel.values());
Collections.sort(docList, sort); Collections.sort(docList, sort);
@SuppressWarnings({"rawtypes"})
List sortedDocs = new ArrayList(rows); List sortedDocs = new ArrayList(rows);
for (Doc doc : docList) { for (Doc doc : docList) {
if (sortedDocs.size() >= rows) break; 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<Comparable, Doc> fullModel) throws Exception { public static void compare(SolrQueryRequest req, String path, Object model,
@SuppressWarnings({"rawtypes"})Map<Comparable, Doc> fullModel) throws Exception {
String strResponse = h.query(req); String strResponse = h.query(req);
Object realResponse = ObjectBuilder.fromJSON(strResponse); Object realResponse = ObjectBuilder.fromJSON(strResponse);

View File

@ -446,7 +446,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
private static Map<String, Level> savedClassLogLevels = new HashMap<>(); private static Map<String, Level> savedClassLogLevels = new HashMap<>();
public static void initClassLogLevels() { public static void initClassLogLevels() {
@SuppressWarnings({"rawtypes"})
Class currentClass = RandomizedContext.current().getTargetClass(); Class currentClass = RandomizedContext.current().getTargetClass();
@SuppressWarnings({"unchecked"})
LogLevel annotation = (LogLevel) currentClass.getAnnotation(LogLevel.class); LogLevel annotation = (LogLevel) currentClass.getAnnotation(LogLevel.class);
if (annotation == null) { if (annotation == null) {
return; return;
@ -1292,6 +1294,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
return msp; return msp;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public static Map map(Object... params) { public static Map map(Object... params) {
LinkedHashMap ret = new LinkedHashMap(); LinkedHashMap ret = new LinkedHashMap();
for (int i=0; i<params.length; i+=2) { for (int i=0; i<params.length; i+=2) {
@ -1442,6 +1445,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
* Appends to the <code>out</code> array with JSON from the <code>doc</code>. * Appends to the <code>out</code> array with JSON from the <code>doc</code>.
* Doesn't currently handle boosts, but does recursively handle child documents * Doesn't currently handle boosts, but does recursively handle child documents
*/ */
@SuppressWarnings({"unchecked"})
public static void json(SolrInputDocument doc, CharArr out) { public static void json(SolrInputDocument doc, CharArr out) {
try { try {
out.append('{'); out.append('{');
@ -1576,7 +1580,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
params = mparams; params = mparams;
} }
String response = updateJ(jsonAdd(sdoc), params); String response = updateJ(jsonAdd(sdoc), params);
@SuppressWarnings({"rawtypes"})
Map rsp = (Map)ObjectBuilder.fromJSON(response); Map rsp = (Map)ObjectBuilder.fromJSON(response);
@SuppressWarnings({"rawtypes"})
List lst = (List)rsp.get("adds"); List lst = (List)rsp.get("adds");
if (lst == null || lst.size() == 0) return null; if (lst == null || lst.size() == 0) return null;
return (Long) lst.get(1); return (Long) lst.get(1);
@ -1589,7 +1595,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
params = mparams; params = mparams;
} }
String response = updateJ(jsonDelId(id), params); String response = updateJ(jsonDelId(id), params);
@SuppressWarnings({"rawtypes"})
Map rsp = (Map)ObjectBuilder.fromJSON(response); Map rsp = (Map)ObjectBuilder.fromJSON(response);
@SuppressWarnings({"rawtypes"})
List lst = (List)rsp.get("deletes"); List lst = (List)rsp.get("deletes");
if (lst == null || lst.size() == 0) return null; if (lst == null || lst.size() == 0) return null;
return (Long) lst.get(1); return (Long) lst.get(1);
@ -1602,7 +1610,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
params = mparams; params = mparams;
} }
String response = updateJ(jsonDelQ(q), params); String response = updateJ(jsonDelQ(q), params);
@SuppressWarnings({"rawtypes"})
Map rsp = (Map)ObjectBuilder.fromJSON(response); Map rsp = (Map)ObjectBuilder.fromJSON(response);
@SuppressWarnings({"rawtypes"})
List lst = (List)rsp.get("deleteByQuery"); List lst = (List)rsp.get("deleteByQuery");
if (lst == null || lst.size() == 0) return null; if (lst == null || lst.size() == 0) return null;
return (Long) lst.get(1); return (Long) lst.get(1);
@ -1613,8 +1623,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
public abstract static class Vals { public abstract static class Vals {
@SuppressWarnings({"rawtypes"})
public abstract Comparable get(); public abstract Comparable get();
public String toJSON(Comparable val) { public String toJSON(@SuppressWarnings({"rawtypes"})Comparable val) {
return JSONUtil.toJSON(val); return JSONUtil.toJSON(val);
} }
@ -1641,6 +1652,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public Comparable get() { public Comparable get() {
return getInt(); return getInt();
} }
@ -1667,6 +1679,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public Comparable get() { public Comparable get() {
return getInt(); return getInt();
} }
@ -1686,6 +1699,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public Comparable get() { public Comparable get() {
return getFloat(); return getFloat();
} }
@ -1694,6 +1708,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
public static class BVal extends Vals { public static class BVal extends Vals {
@Override @Override
@SuppressWarnings({"rawtypes"})
public Comparable get() { public Comparable get() {
return random().nextBoolean(); return random().nextBoolean();
} }
@ -1717,6 +1732,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public Comparable get() { public Comparable get() {
char[] arr = new char[between(minLength,maxLength)]; char[] arr = new char[between(minLength,maxLength)];
for (int i=0; i<arr.length; i++) { for (int i=0; i<arr.length; i++) {
@ -1730,6 +1746,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
public static final IRange ZERO_TWO = new IRange(0,2); public static final IRange ZERO_TWO = new IRange(0,2);
public static final IRange ONE_ONE = new IRange(1,1); public static final IRange ONE_ONE = new IRange(1,1);
@SuppressWarnings({"rawtypes"})
public static class Doc implements Comparable { public static class Doc implements Comparable {
public Comparable id; public Comparable id;
public List<Fld> fields; public List<Fld> fields;
@ -1754,12 +1771,14 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public int compareTo(Object o) { public int compareTo(Object o) {
if (!(o instanceof Doc)) return this.getClass().hashCode() - o.getClass().hashCode(); if (!(o instanceof Doc)) return this.getClass().hashCode() - o.getClass().hashCode();
Doc other = (Doc)o; Doc other = (Doc)o;
return this.id.compareTo(other.id); return this.id.compareTo(other.id);
} }
@SuppressWarnings({"rawtypes"})
public List<Comparable> getValues(String field) { public List<Comparable> getValues(String field) {
for (Fld fld : fields) { for (Fld fld : fields) {
if (fld.ftype.fname.equals(field)) return fld.vals; if (fld.ftype.fname.equals(field)) return fld.vals;
@ -1767,6 +1786,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
return null; return null;
} }
@SuppressWarnings({"rawtypes"})
public Comparable getFirstValue(String field) { public Comparable getFirstValue(String field) {
List<Comparable> vals = getValues(field); List<Comparable> vals = getValues(field);
return vals==null || vals.size()==0 ? null : vals.get(0); 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 static class Fld {
public FldType ftype; public FldType ftype;
@SuppressWarnings({"rawtypes"})
public List<Comparable> vals; public List<Comparable> vals;
@Override @Override
public String toString() { public String toString() {
@ -1811,10 +1832,12 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
this.vals = vals; this.vals = vals;
} }
@SuppressWarnings({"rawtypes"})
public Comparable createValue() { public Comparable createValue() {
return vals.get(); return vals.get();
} }
@SuppressWarnings({"rawtypes"})
public List<Comparable> createValues() { public List<Comparable> createValues() {
int nVals = numValues.getInt(); int nVals = numValues.getInt();
if (nVals <= 0) return null; if (nVals <= 0) return null;
@ -1825,6 +1848,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
public Fld createField() { public Fld createField() {
@SuppressWarnings({"rawtypes"})
List<Comparable> vals = createValues(); List<Comparable> vals = createValues();
if (vals == null) return null; if (vals == null) return null;
@ -1846,6 +1870,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
}); });
} }
@SuppressWarnings({"rawtypes"})
public Map<Comparable,Doc> indexDocs(List<FldType> descriptor, Map<Comparable,Doc> model, int nDocs) throws Exception { public Map<Comparable,Doc> indexDocs(List<FldType> descriptor, Map<Comparable,Doc> model, int nDocs) throws Exception {
if (model == null) { if (model == null) {
model = new LinkedHashMap<>(); model = new LinkedHashMap<>();
@ -1890,6 +1915,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
response = ((Map)response).get("response"); response = ((Map)response).get("response");
response = ((Map)response).get("docs"); response = ((Map)response).get("docs");
@SuppressWarnings({"unchecked"})
List<Map> docList = (List<Map>)response; List<Map> docList = (List<Map>)response;
int order = 0; int order = 0;
for (Map doc : docList) { for (Map doc : docList) {
@ -1966,6 +1992,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
return new Comparator<Doc>() { return new Comparator<Doc>() {
@SuppressWarnings({"rawtypes"})
private Comparable zeroVal(Comparable template) { private Comparable zeroVal(Comparable template) {
if (template == null) return null; if (template == null) return null;
if (template instanceof String) return null; // fast-path for string if (template instanceof String) return null; // fast-path for string
@ -1980,8 +2007,11 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public int compare(Doc o1, Doc o2) { public int compare(Doc o1, Doc o2) {
@SuppressWarnings({"rawtypes"})
Comparable v1 = o1.getFirstValue(field); Comparable v1 = o1.getFirstValue(field);
@SuppressWarnings({"rawtypes"})
Comparable v2 = o2.getFirstValue(field); Comparable v2 = o2.getFirstValue(field);
v1 = v1 == null ? zeroVal(v2) : v1; v1 = v1 == null ? zeroVal(v2) : v1;
@ -2035,7 +2065,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
out.append('['); out.append('[');
} }
boolean firstVal = true; boolean firstVal = true;
for (Comparable val : fld.vals) { for (@SuppressWarnings({"rawtypes"})Comparable val : fld.vals) {
if (firstVal) firstVal=false; if (firstVal) firstVal=false;
else out.append(','); else out.append(',');
out.append(JSONUtil.toJSON(val)); 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 */ /** Return a Map from field value to a list of document ids */
@SuppressWarnings({"rawtypes"})
public Map<Comparable, List<Comparable>> invertField(Map<Comparable, Doc> model, String field) { public Map<Comparable, List<Comparable>> invertField(Map<Comparable, Doc> model, String field) {
Map<Comparable, List<Comparable>> value_to_id = new HashMap<>(); Map<Comparable, List<Comparable>> value_to_id = new HashMap<>();
@ -2344,12 +2375,16 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
if (!(sdoc2.get(key2).getFirstValue() instanceof SolrInputDocument)) { if (!(sdoc2.get(key2).getFirstValue() instanceof SolrInputDocument)) {
return false; return false;
} }
@SuppressWarnings({"rawtypes"})
Collection col1 = (Collection) val1; Collection col1 = (Collection) val1;
@SuppressWarnings({"rawtypes"})
Collection col2 = (Collection) val2; Collection col2 = (Collection) val2;
if (col1.size() != col2.size()) { if (col1.size() != col2.size()) {
return false; return false;
} }
@SuppressWarnings({"unchecked"})
Iterator<SolrInputDocument> colIter1 = col1.iterator(); Iterator<SolrInputDocument> colIter1 = col1.iterator();
@SuppressWarnings({"unchecked"})
Iterator<SolrInputDocument> colIter2 = col2.iterator(); Iterator<SolrInputDocument> colIter2 = col2.iterator();
while (colIter1.hasNext()) { while (colIter1.hasNext()) {
if (!compareSolrInputDocument(colIter1.next(), colIter2.next())) { if (!compareSolrInputDocument(colIter1.next(), colIter2.next())) {
@ -2552,7 +2587,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
} }
public static CloudSolrClientBuilder newCloudSolrClient(String zkHost) { 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); System.clearProperty(SYSTEM_PROPERTY_SOLR_DISABLE_SHARDS_WHITELIST);
} }
@SuppressWarnings({"unchecked"})
protected <T> T pickRandom(T... options) { protected <T> T pickRandom(T... options) {
return options[random().nextInt(options.length)]; return options[random().nextInt(options.length)];
} }
@ -2980,6 +3016,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
* @lucene.experimental * @lucene.experimental
* @lucene.internal * @lucene.internal
*/ */
@SuppressWarnings({"rawtypes"})
private static void randomizeNumericTypesProperties() { private static void randomizeNumericTypesProperties() {
final boolean useDV = random().nextBoolean(); 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; org.apache.solr.schema.PointField.TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGS = false;
System.clearProperty("solr.tests.numeric.points"); System.clearProperty("solr.tests.numeric.points");
System.clearProperty("solr.tests.numeric.points.dv"); 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"); System.clearProperty("solr.tests." + c.getSimpleName() + "FieldType");
} }
private_RANDOMIZED_NUMERIC_FIELDTYPES.clear(); private_RANDOMIZED_NUMERIC_FIELDTYPES.clear();
@ -3059,6 +3096,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
private static boolean isChildDoc(Object o) { private static boolean isChildDoc(Object o) {
if(o instanceof Collection) { if(o instanceof Collection) {
@SuppressWarnings({"rawtypes"})
Collection col = (Collection) o; Collection col = (Collection) o;
if(col.size() == 0) { if(col.size() == 0) {
return false; return false;
@ -3068,6 +3106,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
return o instanceof SolrInputDocument; return o instanceof SolrInputDocument;
} }
@SuppressWarnings({"rawtypes"})
private static final Map<Class,String> private_RANDOMIZED_NUMERIC_FIELDTYPES = new HashMap<>(); private static final Map<Class,String> private_RANDOMIZED_NUMERIC_FIELDTYPES = new HashMap<>();
/** /**
@ -3079,6 +3118,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
* *
* @see #randomizeNumericTypesProperties * @see #randomizeNumericTypesProperties
*/ */
@SuppressWarnings({"rawtypes"})
protected static final Map<Class,String> RANDOMIZED_NUMERIC_FIELDTYPES protected static final Map<Class,String> RANDOMIZED_NUMERIC_FIELDTYPES
= Collections.unmodifiableMap(private_RANDOMIZED_NUMERIC_FIELDTYPES); = Collections.unmodifiableMap(private_RANDOMIZED_NUMERIC_FIELDTYPES);

View File

@ -386,7 +386,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
protected List<JettySolrRunner> createJettys(int numJettys) throws Exception { protected List<JettySolrRunner> createJettys(int numJettys) throws Exception {
List<JettySolrRunner> jettys = Collections.synchronizedList(new ArrayList<>()); List<JettySolrRunner> jettys = Collections.synchronizedList(new ArrayList<>());
List<SolrClient> clients = Collections.synchronizedList(new ArrayList<>()); List<SolrClient> clients = Collections.synchronizedList(new ArrayList<>());
@SuppressWarnings({"rawtypes"})
List<CollectionAdminRequest> createReplicaRequests = Collections.synchronizedList(new ArrayList<>()); List<CollectionAdminRequest> createReplicaRequests = Collections.synchronizedList(new ArrayList<>());
@SuppressWarnings({"rawtypes"})
List<CollectionAdminRequest> createPullReplicaRequests = Collections.synchronizedList(new ArrayList<>()); List<CollectionAdminRequest> createPullReplicaRequests = Collections.synchronizedList(new ArrayList<>());
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -522,7 +524,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
customThreadPool = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createReplicaRequests")); customThreadPool = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createReplicaRequests"));
for (CollectionAdminRequest r : createReplicaRequests) { for (@SuppressWarnings({"rawtypes"})CollectionAdminRequest r : createReplicaRequests) {
customThreadPool.submit(() -> { customThreadPool.submit(() -> {
CollectionAdminResponse response; CollectionAdminResponse response;
try { try {
@ -540,7 +542,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
customThreadPool = ExecutorUtil customThreadPool = ExecutorUtil
.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createPullReplicaRequests")); .newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("createPullReplicaRequests"));
for (CollectionAdminRequest r : createPullReplicaRequests) { for (@SuppressWarnings({"rawtypes"})CollectionAdminRequest r : createPullReplicaRequests) {
customThreadPool.submit(() -> { customThreadPool.submit(() -> {
CollectionAdminResponse response; CollectionAdminResponse response;
try { try {
@ -1801,6 +1803,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
collectionInfos.put(collectionName, list); collectionInfos.put(collectionName, list);
} }
params.set("name", collectionName); params.set("name", collectionName);
@SuppressWarnings({"rawtypes"})
SolrRequest request = new QueryRequest(params); SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections"); request.setPath("/admin/collections");
@ -2403,6 +2406,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
static RequestStatusState getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException { static RequestStatusState getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException {
CollectionAdminResponse response = getStatusResponse(requestId, client); CollectionAdminResponse response = getStatusResponse(requestId, client);
@SuppressWarnings({"rawtypes"})
NamedList innerResponse = (NamedList) response.getResponse().get("status"); NamedList innerResponse = (NamedList) response.getResponse().get("status");
return RequestStatusState.fromKey((String) innerResponse.get("state")); return RequestStatusState.fromKey((String) innerResponse.get("state"));
} }

View File

@ -48,23 +48,28 @@ public class CloudInspectUtil {
* @param bDeleteFails null or list of the ids of deletes that failed for b * @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 * @return true if the difference in a and b is legal
*/ */
@SuppressWarnings({"unchecked"})
public static boolean checkIfDiffIsLegal(SolrDocumentList a, public static boolean checkIfDiffIsLegal(SolrDocumentList a,
SolrDocumentList b, String aName, String bName, Set<String> bAddFails, SolrDocumentList b, String aName, String bName, Set<String> bAddFails,
Set<String> bDeleteFails) { Set<String> bDeleteFails) {
boolean legal = true; boolean legal = true;
@SuppressWarnings({"rawtypes"})
Set<Map> setA = new HashSet<>(); Set<Map> setA = new HashSet<>();
for (SolrDocument sdoc : a) { for (SolrDocument sdoc : a) {
setA.add(new HashMap(sdoc)); setA.add(new HashMap<>(sdoc));
} }
@SuppressWarnings({"rawtypes"})
Set<Map> setB = new HashSet<>(); Set<Map> setB = new HashSet<>();
for (SolrDocument sdoc : b) { for (SolrDocument sdoc : b) {
setB.add(new HashMap(sdoc)); setB.add(new HashMap<>(sdoc));
} }
@SuppressWarnings({"rawtypes"})
Set<Map> onlyInA = new HashSet<>(setA); Set<Map> onlyInA = new HashSet<>(setA);
onlyInA.removeAll(setB); onlyInA.removeAll(setB);
@SuppressWarnings({"rawtypes"})
Set<Map> onlyInB = new HashSet<>(setB); Set<Map> onlyInB = new HashSet<>(setB);
onlyInB.removeAll(setA); onlyInB.removeAll(setA);
@ -75,7 +80,7 @@ public class CloudInspectUtil {
System.err.println("###### Only in " + aName + ": " + onlyInA); System.err.println("###### Only in " + aName + ": " + onlyInA);
System.err.println("###### Only in " + bName + ": " + onlyInB); 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"))) { if (bAddFails == null || !bAddFails.contains(doc.get("id"))) {
legal = false; legal = false;
// System.err.println("###### Only in " + aName + ": " + doc.get("id")); // 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"))) { if (bDeleteFails == null || !bDeleteFails.contains(doc.get("id"))) {
legal = false; legal = false;
// System.err.println("###### Only in " + bName + ": " + doc.get("id")); // System.err.println("###### Only in " + bName + ": " + doc.get("id"));
@ -109,6 +114,7 @@ public class CloudInspectUtil {
* @param bName label for the second list * @param bName label for the second list
* @return the documents only in list a * @return the documents only in list a
*/ */
@SuppressWarnings({"unchecked", "rawtypes"})
public static Set<Map> showDiff(SolrDocumentList a, SolrDocumentList b, public static Set<Map> showDiff(SolrDocumentList a, SolrDocumentList b,
String aName, String bName) { String aName, String bName) {
System.err.println("######" + aName + ": " + toStr(a, 10)); System.err.println("######" + aName + ": " + toStr(a, 10));
@ -203,6 +209,7 @@ public class CloudInspectUtil {
} }
} }
@SuppressWarnings({"rawtypes"})
Set<Map> differences = CloudInspectUtil.showDiff(controlDocList, cloudDocList, Set<Map> differences = CloudInspectUtil.showDiff(controlDocList, cloudDocList,
"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) // 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 // BooleanQuery so we don't trip too many boolean clauses
StringBuilder ids = new StringBuilder("filter(id:("); StringBuilder ids = new StringBuilder("filter(id:(");
for (Map doc : differences) { for (@SuppressWarnings({"rawtypes"})Map doc : differences) {
ids.append(" ").append(doc.get("id")); ids.append(" ").append(doc.get("id"));
foundId = true; foundId = true;
} }

View File

@ -29,6 +29,7 @@ import org.apache.solr.common.params.SolrParams;
* e.g. to add custom components, handlers, parsers, etc. to an otherwise * e.g. to add custom components, handlers, parsers, etc. to an otherwise
* generic configset. * generic configset.
*/ */
@SuppressWarnings({"rawtypes"})
public class ConfigRequest extends SolrRequest { public class ConfigRequest extends SolrRequest {
protected final String message; protected final String message;

View File

@ -64,6 +64,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {
private static final List<String> AUTH_METRICS_TIMER_KEYS = Collections.singletonList("requestTimes"); private static final List<String> AUTH_METRICS_TIMER_KEYS = Collections.singletonList("requestTimes");
private static final String METRICS_PREFIX_PKI = "SECURITY./authentication/pki."; private static final String METRICS_PREFIX_PKI = "SECURITY./authentication/pki.";
private static final String METRICS_PREFIX = "SECURITY./authentication."; private static final String METRICS_PREFIX = "SECURITY./authentication.";
@SuppressWarnings({"rawtypes"})
public static final Predicate NOT_NULL_PREDICATE = o -> o != null; 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_KEYS = Arrays.asList("count");
private static final List<String> AUTH_METRICS_TO_COMPARE = Arrays.asList("requests", "authenticated", "passThrough", "failWrongCredentials", "failMissingCredentials", "errors"); private static final List<String> 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, private static void verifySecurityStatus(HttpClient cl, String url, String objPath,
Object expected, int count, String authHeader) throws IOException, InterruptedException { Object expected, int count, String authHeader) throws IOException, InterruptedException {
boolean success = false; boolean success = false;
@ -198,6 +200,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {
if (authHeader != null) setAuthorizationHeader(get, authHeader); if (authHeader != null) setAuthorizationHeader(get, authHeader);
HttpResponse rsp = cl.execute(get); HttpResponse rsp = cl.execute(get);
s = EntityUtils.toString(rsp.getEntity()); s = EntityUtils.toString(rsp.getEntity());
@SuppressWarnings({"rawtypes"})
Map m = null; Map m = null;
try { try {
m = (Map) Utils.fromJSONString(s); m = (Map) Utils.fromJSONString(s);
@ -207,6 +210,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {
Utils.consumeFully(rsp.getEntity()); Utils.consumeFully(rsp.getEntity());
Object actual = Utils.getObjectByPath(m, true, hierarchy); Object actual = Utils.getObjectByPath(m, true, hierarchy);
if (expected instanceof Predicate) { if (expected instanceof Predicate) {
@SuppressWarnings({"rawtypes"})
Predicate predicate = (Predicate) expected; Predicate predicate = (Predicate) expected;
if (predicate.test(actual)) { if (predicate.test(actual)) {
success = true; success = true;

View File

@ -234,11 +234,13 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
} }
public Builder withDefaultClusterProperty(String key, String value) { public Builder withDefaultClusterProperty(String key, String value) {
@SuppressWarnings({"unchecked"})
HashMap<String, Object> defaults = (HashMap<String, Object>) this.clusterProperties.get(CollectionAdminParams.DEFAULTS); HashMap<String, Object> defaults = (HashMap<String, Object>) this.clusterProperties.get(CollectionAdminParams.DEFAULTS);
if (defaults == null) { if (defaults == null) {
defaults = new HashMap<>(); defaults = new HashMap<>();
this.clusterProperties.put(CollectionAdminParams.DEFAULTS, defaults); this.clusterProperties.put(CollectionAdminParams.DEFAULTS, defaults);
} }
@SuppressWarnings({"unchecked"})
HashMap<String, Object> cluster = (HashMap<String, Object>) defaults.get(CollectionAdminParams.CLUSTER); HashMap<String, Object> cluster = (HashMap<String, Object>) defaults.get(CollectionAdminParams.CLUSTER);
if (cluster == null) { if (cluster == null) {
cluster = new HashMap<>(); cluster = new HashMap<>();
@ -447,6 +449,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
} }
} }
@SuppressWarnings({"rawtypes"})
protected NamedList waitForResponse(Predicate<NamedList> predicate, SolrRequest request, int intervalInMillis, int numRetries, String messageOnFail) { protected NamedList waitForResponse(Predicate<NamedList> predicate, SolrRequest request, int intervalInMillis, int numRetries, String messageOnFail) {
log.info("waitForResponse: {}", request); log.info("waitForResponse: {}", request);
int i = 0; int i = 0;

View File

@ -29,7 +29,7 @@ public class MockTracerConfigurator extends TracerConfigurator {
} }
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
} }
} }

View File

@ -135,8 +135,9 @@ public @interface RandomizeSSL {
/** /**
* Returns an SSLRandomizer suitable for the specified (test) class * 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); final SuppressSSL suppression = (SuppressSSL) clazz.getAnnotation(SuppressSSL.class);
if (null != suppression) { if (null != suppression) {
// Even if this class has a RandomizeSSL annotation, any usage of SuppressSSL -- even in a // 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()); return new SSLRandomizer(0.0D, 0.0D, suppression.toString());
} }
@SuppressWarnings({"unchecked"})
final RandomizeSSL annotation = (RandomizeSSL) clazz.getAnnotation(RandomizeSSL.class); final RandomizeSSL annotation = (RandomizeSSL) clazz.getAnnotation(RandomizeSSL.class);
if (null == annotation) { if (null == annotation) {

View File

@ -274,7 +274,7 @@ public class TestHarness extends BaseTestHarness {
} }
return connection.request(handler, null, xml); return connection.request(handler, null, xml);
} catch (SolrException e) { } catch (SolrException e) {
throw (SolrException)e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 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 * Perhaps the best we could do is increment the core reference count
* and decrement it in the request close() method? * and decrement it in the request close() method?
*/ */
@SuppressWarnings({"unchecked"})
public LocalSolrQueryRequest makeRequest(String ... q) { public LocalSolrQueryRequest makeRequest(String ... q) {
if (q.length==1) { if (q.length==1) {
return new LocalSolrQueryRequest(TestHarness.this.getCore(), return new LocalSolrQueryRequest(TestHarness.this.getCore(),
@ -444,10 +445,12 @@ public class TestHarness extends BaseTestHarness {
if (q.length%2 != 0) { if (q.length%2 != 0) {
throw new RuntimeException("The length of the string array (query arguments) needs to be even"); throw new RuntimeException("The length of the string array (query arguments) needs to be even");
} }
@SuppressWarnings({"rawtypes"})
Map.Entry<String, String> [] entries = new NamedListEntry[q.length / 2]; Map.Entry<String, String> [] entries = new NamedListEntry[q.length / 2];
for (int i = 0; i < q.length; i += 2) { for (int i = 0; i < q.length; i += 2) {
entries[i/2] = new NamedListEntry<>(q[i], q[i+1]); entries[i/2] = new NamedListEntry<>(q[i], q[i+1]);
} }
@SuppressWarnings({"rawtypes"})
NamedList nl = new NamedList(entries); NamedList nl = new NamedList(entries);
if(nl.get("wt" ) == null) nl.add("wt","xml"); if(nl.get("wt" ) == null) nl.add("wt","xml");
return new LocalSolrQueryRequest(TestHarness.this.getCore(), nl); return new LocalSolrQueryRequest(TestHarness.this.getCore(), nl);