diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6bce15f7e16..287d9fb3c56 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -290,6 +290,8 @@ Other Changes
* SOLR-14538: Fix or suppress remaining warnings in apache/solr/handler (Erick Erickson)
+* SOLR-14536: Fix or suppress warnings in apache/solr/common (Erick Erickson)
+
================== 8.5.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 7cea4cf87e2..c2e7869f9fc 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -110,6 +110,7 @@ public CollectionAdminRequest(String path, CollectionAction action) {
}
@Override
+ @SuppressWarnings({"rawtypes"})
public SolrRequest getV2Request() {
return usev2 ?
V1toV2ApiMapper.convert(this).useBinary(useBinaryV2).build() :
@@ -294,6 +295,7 @@ public SolrParams getParams() {
}
}
+ @SuppressWarnings({"rawtypes"})
protected abstract static class ShardSpecificAdminRequest extends CollectionAdminRequest {
protected String collection;
@@ -1535,6 +1537,7 @@ private ForceLeader(String collection, String shard) {
public static class RequestStatusResponse extends CollectionAdminResponse {
public RequestStatusState getRequestStatus() {
+ @SuppressWarnings({"rawtypes"})
NamedList innerResponse = (NamedList) getResponse().get("status");
return RequestStatusState.fromKey((String) innerResponse.get("state"));
}
@@ -2682,6 +2685,7 @@ protected CollectionAdminResponse createResponse(SolrClient client) {
/**
* Returns a SolrRequest to get a list of collections in the cluster
*/
+ @SuppressWarnings({"unchecked"})
public static java.util.List listCollections(SolrClient client) throws IOException, SolrServerException {
CollectionAdminResponse resp = new List().process(client);
return (java.util.List) resp.getResponse().get("collections");
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V1toV2ApiMapper.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V1toV2ApiMapper.java
index 0ec1112c214..0cfaf201b75 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V1toV2ApiMapper.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V1toV2ApiMapper.java
@@ -84,6 +84,7 @@ synchronized void setPath() {
public V2Request.Builder convert(SolrParams paramsV1) {
String[] list = new String[template.variables.size()];
MapWriter data = serializeToV2Format(paramsV1, list);
+ @SuppressWarnings({"rawtypes"})
Map o = data.toMap(new LinkedHashMap<>());
return new V2Request.Builder(template.apply(s -> {
int idx = template.variables.indexOf(s);
diff --git a/solr/solrj/src/java/org/apache/solr/common/IteratorWriter.java b/solr/solrj/src/java/org/apache/solr/common/IteratorWriter.java
index ec11c786d02..143506d9a70 100644
--- a/solr/solrj/src/java/org/apache/solr/common/IteratorWriter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/IteratorWriter.java
@@ -74,6 +74,7 @@ default ItemWriter add(boolean v) throws IOException {
return this;
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
default List toList( List l) {
try {
writeIter(new ItemWriter() {
diff --git a/solr/solrj/src/java/org/apache/solr/common/MapSerializable.java b/solr/solrj/src/java/org/apache/solr/common/MapSerializable.java
index 7fadc2ebee1..f56f1b2e1c2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/MapSerializable.java
+++ b/solr/solrj/src/java/org/apache/solr/common/MapSerializable.java
@@ -26,5 +26,6 @@ public interface MapSerializable {
* Do not keep a reference to the passed map and reuse it.
* it may be reused by the framework
*/
+ @SuppressWarnings({"rawtypes"})
Map toMap(Map map);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/MapWriter.java b/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
index 926cf4c360d..726641023d1 100644
--- a/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
@@ -40,6 +40,7 @@ default String jsonStr(){
}
@Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
default Map toMap(Map map) {
try {
writeMap(new EntryWriter() {
diff --git a/solr/solrj/src/java/org/apache/solr/common/MapWriterMap.java b/solr/solrj/src/java/org/apache/solr/common/MapWriterMap.java
index f6b978fded7..8b35c9642a3 100644
--- a/solr/solrj/src/java/org/apache/solr/common/MapWriterMap.java
+++ b/solr/solrj/src/java/org/apache/solr/common/MapWriterMap.java
@@ -22,24 +22,28 @@
import java.util.Map;
public class MapWriterMap implements MapWriter {
+ @SuppressWarnings({"rawtypes"})
private final Map delegate;
- public MapWriterMap(Map delegate) {
+ public MapWriterMap(@SuppressWarnings({"rawtypes"})Map delegate) {
this.delegate = delegate;
}
@Override
+ @SuppressWarnings({"unchecked"})
public void writeMap(EntryWriter ew) throws IOException {
delegate.forEach(ew.getBiConsumer());
}
@Override
+ @SuppressWarnings({"unchecked"})
public Object _get(String path, Object def) {
if (path.indexOf('/') == -1) return delegate.getOrDefault(path, def);
return MapWriter.super._get(path, def);
}
@Override
+ @SuppressWarnings({"unchecked"})
public Object _get(List path, Object def) {
if (path.size() == 1) return delegate.getOrDefault(path.get(0), def);
return MapWriter.super._get(path, def);
@@ -47,6 +51,7 @@ public Object _get(List path, Object def) {
@Override
+ @SuppressWarnings({"rawtypes"})
public Map toMap(Map map) {
return delegate;
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java b/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
index ccef7e2fc14..22dca2bbe40 100644
--- a/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
+++ b/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
@@ -53,20 +53,20 @@ default String _getStr(String path, String def) {
/**Iterate through the entries of a navigable Object at a certain path
* @param path the json path
*/
- default void _forEachEntry(String path, BiConsumer fun) {
+ default void _forEachEntry(String path, @SuppressWarnings({"rawtypes"})BiConsumer fun) {
Utils.forEachMapEntry(this, path, fun);
}
/**Iterate through the entries of a navigable Object at a certain path
* @param path the json path
*/
- default void _forEachEntry(List path, BiConsumer fun) {
+ default void _forEachEntry(List path, @SuppressWarnings({"rawtypes"})BiConsumer fun) {
Utils.forEachMapEntry(this, path, fun);
}
/**Iterate through each entry in this object
*/
- default void _forEachEntry(BiConsumer fun) {
+ default void _forEachEntry(@SuppressWarnings({"rawtypes"})BiConsumer fun) {
Utils.forEachMapEntry(this, fun);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java b/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java
index 21d79a97fd4..d309719febe 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java
@@ -48,6 +48,7 @@ public abstract class SolrDocumentBase implements Map, Serializ
/**
* Get a collection of values for a given field name
*/
+ @SuppressWarnings({"rawtypes"})
public abstract Collection getFieldValues(String name);
public abstract void addChildDocument(K child);
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrException.java b/solr/solrj/src/java/org/apache/solr/common/SolrException.java
index 673bae7212a..9909c2b719c 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrException.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrException.java
@@ -33,7 +33,7 @@ public class SolrException extends RuntimeException {
public static final String ROOT_ERROR_CLASS = "root-error-class";
public static final String ERROR_CLASS = "error-class";
- final private Map mdcContext;
+ final private Map mdcContext;
/**
* This list of valid HTTP Status error codes that Solr may return in
@@ -160,13 +160,12 @@ public static void log(Logger log, String msg, Throwable e) {
}
public static void log(Logger log, String msg) {
- String stackTrace = msg;
- String ignore = doIgnore(null, stackTrace);
+ String ignore = doIgnore(null, msg);
if (ignore != null) {
log.info(ignore);
return;
}
- log.error(stackTrace);
+ log.error(msg);
}
// public String toString() { return toStr(this); } // oops, inf loop
@@ -225,8 +224,9 @@ public static Throwable getRootCause(Throwable t) {
return t;
}
+ @SuppressWarnings({"unchecked"})
public void logInfoWithMdc(Logger logger, String msg) {
- Map previousMdcContext = MDC.getCopyOfContextMap();
+ Map previousMdcContext = MDC.getCopyOfContextMap();
MDC.setContextMap(mdcContext);
try {
logger.info(msg);
@@ -236,7 +236,7 @@ public void logInfoWithMdc(Logger logger, String msg) {
}
public void logDebugWithMdc(Logger logger, String msg) {
- Map previousMdcContext = MDC.getCopyOfContextMap();
+ Map previousMdcContext = MDC.getCopyOfContextMap();
MDC.setContextMap(mdcContext);
try {
logger.debug(msg);
@@ -246,7 +246,7 @@ public void logDebugWithMdc(Logger logger, String msg) {
}
public void logWarnWithMdc(Logger logger, String msg) {
- Map previousMdcContext = MDC.getCopyOfContextMap();
+ Map previousMdcContext = MDC.getCopyOfContextMap();
MDC.setContextMap(mdcContext);
try {
logger.warn(msg);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
index 96e53718f9c..2f0779cbd06 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
@@ -108,6 +108,7 @@ public Map getClusterProperties() throws IOException {
public void setClusterProperties(Map properties) throws IOException, KeeperException, InterruptedException {
client.atomicUpdate(ZkStateReader.CLUSTER_PROPS, zkData -> {
if (zkData == null) return Utils.toJSON(convertCollectionDefaultsToNestedFormat(properties));
+ @SuppressWarnings({"unchecked"})
Map zkJson = (Map) Utils.fromJSON(zkData);
zkJson = convertCollectionDefaultsToNestedFormat(zkJson);
boolean modified = Utils.mergeJson(zkJson, convertCollectionDefaultsToNestedFormat(properties));
@@ -122,6 +123,7 @@ public void setClusterProperties(Map properties) throws IOExcept
* @param properties the properties to be converted
* @return the converted map
*/
+ @SuppressWarnings({"unchecked"})
static Map convertCollectionDefaultsToNestedFormat(Map properties) {
if (properties.containsKey(COLLECTION_DEF)) {
Map values = (Map) properties.remove(COLLECTION_DEF);
@@ -161,6 +163,7 @@ public void setClusterProperty(String propertyName, Object propertyValue) throws
Stat s = new Stat();
try {
if (client.exists(ZkStateReader.CLUSTER_PROPS, true)) {
+ @SuppressWarnings({"rawtypes"})
Map properties = (Map) Utils.fromJSON(client.getData(ZkStateReader.CLUSTER_PROPS, null, s, true));
if (propertyValue == null) {
//Don't update ZK unless absolutely necessary.
@@ -176,6 +179,7 @@ public void setClusterProperty(String propertyName, Object propertyValue) throws
}
}
} else {
+ @SuppressWarnings({"rawtypes"})
Map properties = new LinkedHashMap();
properties.put(propertyName, propertyValue);
client.create(ZkStateReader.CLUSTER_PROPS, Utils.toJSON(properties), CreateMode.PERSISTENT, true);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
index a60a2759e90..62288c82aca 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
@@ -32,6 +32,7 @@
import org.apache.zookeeper.ZooKeeper;
// we use this class to expose nasty stuff for tests
+@SuppressWarnings({"try"})
public class SolrZooKeeper extends ZooKeeper {
final Set spawnedThreads = new CopyOnWriteArraySet<>();
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index ae28149146a..4065d3c0d48 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -243,6 +243,7 @@ public AutoScalingConfig getAutoScalingConfig() throws KeeperException, Interrup
* @return current configuration from autoscaling.json
. NOTE:
* this data is retrieved from ZK on each call.
*/
+ @SuppressWarnings({"unchecked"})
public AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws KeeperException, InterruptedException {
Stat stat = new Stat();
@@ -487,6 +488,7 @@ public Integer compareStateVersions(String coll, int version) {
return collection.getZNodeVersion();
}
+ @SuppressWarnings({"unchecked"})
public synchronized void createClusterStateWatchersAndUpdate() throws KeeperException,
InterruptedException {
// We need to fetch the current cluster state and the set of live nodes
@@ -1085,6 +1087,7 @@ public T getClusterProperty(String key, T defaultValue) {
* @param defaultValue a default value to use if no such property exists
* @return the cluster property, or a default if the property is not set
*/
+ @SuppressWarnings({"unchecked"})
public T getClusterProperty(List keyPath, T defaultValue) {
T value = (T) Utils.getObjectByPath(clusterProperties, false, keyPath);
if (value == null)
@@ -1256,6 +1259,7 @@ private VersionedCollectionProps fetchCollectionProperties(String collection, Wa
* Returns the content of /security.json from ZooKeeper as a Map
* If the files doesn't exist, it returns null.
*/
+ @SuppressWarnings({"unchecked"})
public ConfigData getSecurityProps(boolean getFresh) {
if (!getFresh) {
if (securityData == null) return new ConfigData(EMPTY_MAP, -1);
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java b/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
index 08022b2e4de..c729534ba40 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
@@ -458,7 +458,7 @@ public static SolrParams wrapAppended(SolrParams params, SolrParams defaults) {
/** Create a Map<String,String> from a NamedList given no keys are repeated */
@Deprecated // Doesn't belong here (no SolrParams). Just remove.
- public static Map toMap(NamedList params) {
+ public static Map toMap(@SuppressWarnings({"rawtypes"})NamedList params) {
HashMap map = new HashMap<>();
for (int i=0; i toMap(NamedList params) {
/** Create a Map<String,String[]> from a NamedList */
@Deprecated // Doesn't belong here (no SolrParams). Just remove.
- public static Map toMultiMap(NamedList params) {
+ public static Map toMultiMap(@SuppressWarnings({"rawtypes"})NamedList params) {
HashMap map = new HashMap<>();
for (int i=0; i toMultiMap(NamedList params) {
if (val instanceof String[]) {
MultiMapSolrParams.addParam(name, (String[]) val, map);
} else if (val instanceof List) {
+ @SuppressWarnings({"rawtypes"})
List l = (List) val;
String[] s = new String[l.size()];
for (int j = 0; j < l.size(); j++) {
@@ -494,7 +495,7 @@ public static Map toMultiMap(NamedList params) {
* @deprecated Use {@link NamedList#toSolrParams()}.
*/
@Deprecated //move to NamedList to allow easier flow
- public static SolrParams toSolrParams(NamedList params) {
+ public static SolrParams toSolrParams(@SuppressWarnings({"rawtypes"})NamedList params) {
return params.toSolrParams();
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java b/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
index 7a4abe2c303..0a65b0d62f2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
@@ -180,6 +180,7 @@ public ByteArrayUtf8CharSequence deepCopy() {
return new ByteArrayUtf8CharSequence(bytes, 0, length, utf16, hashCode);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Map.Entry convertCharSeq(Map.Entry e) {
if (e.getKey() instanceof Utf8CharSequence || e.getValue() instanceof Utf8CharSequence) {
return new AbstractMap.SimpleEntry(convertCharSeq(e.getKey()), convertCharSeq(e.getValue()));
@@ -188,6 +189,7 @@ public static Map.Entry convertCharSeq(Map.Entry e) {
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Collection convertCharSeq(Collection vals) {
if (vals == null) return vals;
boolean needsCopy = false;
@@ -200,9 +202,9 @@ public static Collection convertCharSeq(Collection vals) {
if (needsCopy) {
Collection copy = null;
if (vals instanceof Set){
- copy = new HashSet(vals.size());
+ copy = new HashSet<>(vals.size());
} else {
- copy = new ArrayList(vals.size());
+ copy = new ArrayList<>(vals.size());
}
for (Object o : vals) copy.add(convertCharSeq(o));
return copy;
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java b/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java
index 84c35bd21d9..c5ebd06f664 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java
@@ -472,9 +472,11 @@ public void stream(EntryImpl entry, StreamCodec codec) throws IOException {
}
@Override
+ @SuppressWarnings({"unchecked"})
public Object readObject(StreamCodec codec, EntryImpl entry) throws IOException {
SolrDocumentList solrDocs = new SolrDocumentList();
if(entry.metadata != null){
+ @SuppressWarnings({"rawtypes"})
List list = (List) entry.metadata;
solrDocs.setNumFound((Long) list.get(0));
solrDocs.setStart((Long) list.get(1));
@@ -779,6 +781,7 @@ public void skip(EntryImpl entry, StreamCodec codec) throws IOException {
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
private static void addObj(DataEntry e) {
if (e.type().isContainer) {
Object ctx = e.type() == DataEntry.Type.KEYVAL_ITER ?
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
index bd86db91ab2..fb45e883fe3 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
@@ -351,6 +351,7 @@ protected Object readObject(DataInputInputStream dis) throws IOException {
throw new RuntimeException("Unknown type " + tagByte);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public boolean writeKnownType(Object val) throws IOException {
if (writePrimitive(val)) return true;
if (val instanceof NamedList) {
@@ -752,7 +753,7 @@ public void writeIterator(IteratorWriter val) throws IOException {
val.writeIter(itemWriter);
writeTag(END);
}
- public void writeIterator(Iterator iter) throws IOException {
+ public void writeIterator(@SuppressWarnings({"rawtypes"})Iterator iter) throws IOException {
writeTag(ITERATOR);
while (iter.hasNext()) {
writeVal(iter.next());
@@ -770,14 +771,14 @@ public List
*
*/
+@SuppressWarnings({"unchecked", "rawtypes"})
public class NamedList implements Cloneable, Serializable, Iterable> , MapWriter {
private static final long serialVersionUID = 1957981902839867821L;
@@ -467,9 +468,11 @@ public T remove(Object key) {
}
@Override
+ @SuppressWarnings({"unchecked"})
public void putAll(Map m) {
boolean isEmpty = isEmpty();
for (Object o : m.entrySet()) {
+ @SuppressWarnings({"rawtypes"})
Map.Entry e = (Entry) o;
if (isEmpty) {// we know that there are no duplicates
add((String) e.getKey(), (T) e.getValue());
@@ -485,12 +488,14 @@ public void clear() {
}
@Override
+ @SuppressWarnings({"unchecked"})
public Set keySet() {
//TODO implement more efficiently
return NamedList.this.asMap(1).keySet();
}
@Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
public Collection values() {
//TODO implement more efficiently
return NamedList.this.asMap(1).values();
@@ -795,7 +800,6 @@ public Boolean getBooleanArg(final String name) {
* If values are found for the input key that are not strings or
* arrays of strings.
*/
- @SuppressWarnings("rawtypes")
public Collection removeConfigArgs(final String name)
throws SolrException {
List objects = getAll(name);
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Pair.java b/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
index 74f5b2d6ff7..05b09e850b8 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Pair.java
@@ -66,6 +66,7 @@ public void writeMap(EntryWriter ew) throws IOException {
ew.put("second", second);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Pair parse(Map m) {
return new Pair(m.get("first"), m.get("second"));
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/TextWriter.java b/solr/solrj/src/java/org/apache/solr/common/util/TextWriter.java
index 6aa58c6a8fa..bb3975628f6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/TextWriter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/TextWriter.java
@@ -93,9 +93,9 @@ default void writeVal(String name, Object val) throws IOException {
void writeStr(String name, String val, boolean needsEscaping) throws IOException;
- void writeMap(String name, Map val, boolean excludeOuter, boolean isFirstVal) throws IOException;
+ void writeMap(String name, @SuppressWarnings({"rawtypes"})Map val, boolean excludeOuter, boolean isFirstVal) throws IOException;
- void writeArray(String name, Iterator val) throws IOException;
+ void writeArray(String name, @SuppressWarnings({"rawtypes"})Iterator val) throws IOException;
void writeNull(String name) throws IOException;
@@ -121,7 +121,7 @@ default void writeVal(String name, Object val) throws IOException {
/** if this form of the method is called, val is the Solr ISO8601 based date format */
void writeDate(String name, String val) throws IOException;
- void writeNamedList(String name, NamedList val) throws IOException;
+ void writeNamedList(String name, @SuppressWarnings({"rawtypes"})NamedList val) throws IOException;
Writer getWriter();
@@ -154,7 +154,7 @@ default void writeArray(String name, Object[] val) throws IOException {
writeArray(name, Arrays.asList(val));
}
- default void writeArray(String name, List l) throws IOException {
+ default void writeArray(String name, @SuppressWarnings({"rawtypes"})List l) throws IOException {
writeArray(name, l.iterator());
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
index e32a4265f70..229417a969d 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
@@ -89,30 +89,39 @@
import static java.util.concurrent.TimeUnit.NANOSECONDS;
public class Utils {
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_HASHMAP_FUN = o -> new HashMap<>();
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_LINKED_HASHMAP_FUN = o -> new LinkedHashMap<>();
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_ATOMICLONG_FUN = o -> new AtomicLong();
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_ARRAYLIST_FUN = o -> new ArrayList<>();
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_SYNCHRONIZED_ARRAYLIST_FUN = o -> Collections.synchronizedList(new ArrayList<>());
+ @SuppressWarnings({"rawtypes"})
public static final Function NEW_HASHSET_FUN = o -> new HashSet<>();
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ @SuppressWarnings({"rawtypes"})
public static Map getDeepCopy(Map map, int maxDepth) {
return getDeepCopy(map, maxDepth, true, false);
}
+ @SuppressWarnings({"rawtypes"})
public static Map getDeepCopy(Map map, int maxDepth, boolean mutable) {
return getDeepCopy(map, maxDepth, mutable, false);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Map getDeepCopy(Map map, int maxDepth, boolean mutable, boolean sorted) {
if (map == null) return null;
if (maxDepth < 1) return map;
Map copy;
if (sorted) {
- copy = new TreeMap();
+ copy = new TreeMap<>();
} else {
- copy = map instanceof LinkedHashMap ? new LinkedHashMap(map.size()) : new HashMap(map.size());
+ copy = map instanceof LinkedHashMap ? new LinkedHashMap<>(map.size()) : new HashMap<>(map.size());
}
for (Object o : map.entrySet()) {
Map.Entry e = (Map.Entry) o;
@@ -121,17 +130,18 @@ public static Map getDeepCopy(Map map, int maxDepth, boolean mutable, boolean so
return mutable ? copy : Collections.unmodifiableMap(copy);
}
- public static void forEachMapEntry(Object o, String path, BiConsumer fun) {
+ public static void forEachMapEntry(Object o, String path, @SuppressWarnings({"rawtypes"})BiConsumer fun) {
Object val = Utils.getObjectByPath(o, false, path);
forEachMapEntry(val, fun);
}
- public static void forEachMapEntry(Object o, List path, BiConsumer fun) {
+ public static void forEachMapEntry(Object o, List path, @SuppressWarnings({"rawtypes"})BiConsumer fun) {
Object val = Utils.getObjectByPath(o, false, path);
forEachMapEntry(val, fun);
}
- public static void forEachMapEntry(Object o, BiConsumer fun) {
+ @SuppressWarnings({"unchecked"})
+ public static void forEachMapEntry(Object o, @SuppressWarnings({"rawtypes"})BiConsumer fun) {
if (o instanceof MapWriter) {
MapWriter m = (MapWriter) o;
try {
@@ -150,6 +160,7 @@ public MapWriter.EntryWriter put(CharSequence k, Object v) {
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
private static Object makeDeepCopy(Object v, int maxDepth, boolean mutable, boolean sorted) {
if (v instanceof MapWriter && maxDepth > 1) {
v = ((MapWriter) v).toMap(new LinkedHashMap<>());
@@ -182,10 +193,12 @@ public static Object fromJavabin(byte[] bytes) throws IOException {
}
}
+ @SuppressWarnings({"rawtypes"})
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable) {
return getDeepCopy(c, maxDepth, mutable, false);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable, boolean sorted) {
if (c == null || maxDepth < 1) return c;
Collection result = c instanceof Set ?
@@ -217,6 +230,7 @@ public MapWriterJSONWriter(CharArr out, int indentSize) {
}
@Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
public void handleUnknownClass(Object o) {
if (o instanceof MapWriter) {
Map m = ((MapWriter) o).toMap(new LinkedHashMap<>());
@@ -313,7 +327,7 @@ public static Object fromJSON(Reader is) {
return new ObjectBuilder(jsonParser) {
@Override
public Object newObject() {
- return new LinkedHashMapWriter();
+ return new LinkedHashMapWriter<>();
}
};
} catch (IOException e) {
@@ -326,7 +340,7 @@ public Object newObject() {
return new ObjectBuilder(jsonParser) {
@Override
public Object newObject() {
- return new HashMap();
+ return new HashMap<>();
}
};
} catch (IOException e) {
@@ -384,11 +398,13 @@ public static Object getObjectByPath(Object root, boolean onlyPrimitive, String
return getObjectByPath(root, onlyPrimitive, parts);
}
+ @SuppressWarnings({"unchecked"})
public static boolean setObjectByPath(Object root, String hierarchy, Object value) {
List parts = StrUtils.splitSmart(hierarchy, '/', true);
return setObjectByPath(root, parts, value);
}
+ @SuppressWarnings({"unchecked"})
public static boolean setObjectByPath(Object root, List hierarchy, Object value) {
if (root == null) return false;
if (!isMapLike(root)) throw new RuntimeException("must be a Map or NamedList");
@@ -407,6 +423,7 @@ public static boolean setObjectByPath(Object root, List hierarchy, Objec
Object o = getVal(obj, s, -1);
if (o == null) return false;
if (idx > -1) {
+ @SuppressWarnings({"rawtypes"})
List l = (List) o;
o = idx < l.size() ? l.get(idx) : null;
}
@@ -415,6 +432,7 @@ public static boolean setObjectByPath(Object root, List hierarchy, Objec
} else {
if (idx == -2) {
if (obj instanceof NamedList) {
+ @SuppressWarnings({"rawtypes"})
NamedList namedList = (NamedList) obj;
int location = namedList.indexOf(s, 0);
if (location == -1) namedList.add(s, value);
@@ -426,6 +444,7 @@ public static boolean setObjectByPath(Object root, List hierarchy, Objec
} else {
Object v = getVal(obj, s, -1);
if (v instanceof List) {
+ @SuppressWarnings({"rawtypes"})
List list = (List) v;
if (idx == -1) {
list.add(value);
@@ -469,6 +488,7 @@ public static Object getObjectByPath(Object root, boolean onlyPrimitive, List getJson(DistribStateManager distribStateManager, String path) throws InterruptedException, IOException, KeeperException {
VersionedData data = null;
try {
@@ -614,6 +637,7 @@ public static Map getJson(DistribStateManager distribStateManage
* @param retryOnConnLoss whether to retry the operation automatically on connection loss, see {@link org.apache.solr.common.cloud.ZkCmdExecutor#retryOperation(ZkOperation)}
* @return a Map if the node exists and contains valid JSON or an empty map if znode does not exist or has a null data
*/
+ @SuppressWarnings({"unchecked"})
public static Map getJson(SolrZkClient zkClient, String path, boolean retryOnConnLoss) throws KeeperException, InterruptedException {
try {
byte[] bytes = zkClient.getData(path, null, null, retryOnConnLoss);
@@ -663,6 +687,7 @@ public static String parseMetricsReplicaName(String collectionName, String coreN
* @param input the json with new values
* @return whether there was any change made to sink or not.
*/
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static boolean mergeJson(Map sink, Map input) {
boolean isModified = false;
for (Map.Entry e : input.entrySet()) {
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
index b5375365fea..4d76d52b248 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
@@ -48,6 +48,7 @@ public class ValidatingJsonMap implements Map, NavigableObject {
if (o == null) return " Must not be NULL";
return null;
};
+ @SuppressWarnings({"rawtypes"})
public static final PredicateWithErrMsg ENUM_OF = pair -> {
if (pair.second() instanceof Set) {
Set set = (Set) pair.second();
@@ -141,7 +142,8 @@ public Set> entrySet() {
return delegate.entrySet();
}
- public Object get(String key, PredicateWithErrMsg predicate) {
+ @SuppressWarnings({"unchecked"})
+ public Object get(String key, @SuppressWarnings({"rawtypes"})PredicateWithErrMsg predicate) {
Object v = get(key);
if (predicate != null) {
String msg = predicate.test(v);
@@ -178,11 +180,12 @@ public ValidatingJsonMap getMap(String key) {
return getMap(key, null, null);
}
- public ValidatingJsonMap getMap(String key, PredicateWithErrMsg predicate) {
+ public ValidatingJsonMap getMap(String key, @SuppressWarnings({"rawtypes"})PredicateWithErrMsg predicate) {
return getMap(key, predicate, null);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public ValidatingJsonMap getMap(String key, PredicateWithErrMsg predicate, String message) {
Object v = get(key);
if (v != null && !(v instanceof Map)) {
@@ -199,10 +202,12 @@ public ValidatingJsonMap getMap(String key, PredicateWithErrMsg predicate, Strin
return wrap((Map) v);
}
+ @SuppressWarnings({"rawtypes"})
public List getList(String key, PredicateWithErrMsg predicate) {
return getList(key, predicate, null);
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public List getList(String key, PredicateWithErrMsg predicate, Object test) {
Object v = get(key);
if (v != null && !(v instanceof List)) {
@@ -219,6 +224,7 @@ public List getList(String key, PredicateWithErrMsg predicate, Object test) {
return (List) v;
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public Object get(String key, PredicateWithErrMsg predicate, Object arg) {
Object v = get(key);
String test = predicate.test(new Pair(v, arg));
@@ -279,6 +285,7 @@ private static void handleIncludes(ValidatingJsonMap map, String location, int m
}
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static ValidatingJsonMap getDeepCopy(Map map, int maxDepth, boolean mutable) {
if (map == null) return null;
if (maxDepth < 1) return ValidatingJsonMap.wrap(map);
@@ -293,6 +300,7 @@ public static ValidatingJsonMap getDeepCopy(Map map, int maxDepth, boolean mutab
return mutable ? copy : new ValidatingJsonMap(Collections.unmodifiableMap(copy));
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable) {
if (c == null || maxDepth < 1) return c;
Collection result = c instanceof Set ? new HashSet() : new ArrayList();
@@ -339,6 +347,7 @@ public boolean equals(Object that) {
return that instanceof Map && this.delegate.equals(that);
}
+ @SuppressWarnings({"unchecked"})
public static final ValidatingJsonMap EMPTY = new ValidatingJsonMap(Collections.EMPTY_MAP);
public interface PredicateWithErrMsg {