SOLR-14567: Fix or suppress remaining warnings in solrj

This commit is contained in:
Erick Erickson 2020-06-14 08:11:23 -04:00
parent 396490b65c
commit 4e90e48ac2
65 changed files with 262 additions and 58 deletions

View File

@ -340,6 +340,8 @@ Other Changes
* SOLR-14564: Fix or suppress remaining warnings in solr/core (Erick Erickson)
* SOLR-14567: Fix or suppress remaining warnings in solrj (Erick Erickson)
================== 8.5.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -1273,7 +1273,7 @@ public abstract class SolrClient implements Serializable, Closeable {
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public abstract NamedList<Object> request(final SolrRequest request, String collection)
public abstract NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection)
throws SolrServerException, IOException;
/**
@ -1286,7 +1286,7 @@ public abstract class SolrClient implements Serializable, Closeable {
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public final NamedList<Object> request(final SolrRequest request) throws SolrServerException, IOException {
public final NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request) throws SolrServerException, IOException {
return request(request, null);
}

View File

@ -74,6 +74,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
/**If set to true, every request that implements {@link V2RequestSupport} will be converted
* to a V2 API call
*/
@SuppressWarnings({"rawtypes"})
public SolrRequest setUseV2(boolean flag){
this.usev2 = flag;
return this;
@ -81,6 +82,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
/**If set to true use javabin instead of json (default)
*/
@SuppressWarnings({"rawtypes"})
public SolrRequest setUseBinaryV2(boolean flag){
this.useBinaryV2 = flag;
return this;
@ -90,6 +92,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
private String basePath;
@SuppressWarnings({"rawtypes"})
public SolrRequest setBasicAuthCredentials(String user, String password) {
this.basicAuthUser = user;
this.basicAuthPwd = password;

View File

@ -55,6 +55,7 @@ public abstract class SolrResponse implements Serializable, MapWriter {
}
public Exception getException() {
@SuppressWarnings({"rawtypes"})
NamedList exp = (NamedList) getResponse().get("exception");
if (exp == null) {
return null;

View File

@ -26,5 +26,6 @@ public interface V2RequestSupport {
* return V1 request object
*
*/
@SuppressWarnings({"rawtypes"})
SolrRequest getV2Request();
}

View File

@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
*/
public class DocumentObjectBinder {
@SuppressWarnings({"rawtypes"})
private final Map<Class, List<DocField>> infocache = new ConcurrentHashMap<>();
public DocumentObjectBinder() {
@ -83,6 +84,7 @@ public class DocumentObjectBinder {
if (field.dynamicFieldNamePatternMatcher != null &&
field.get(obj) != null &&
field.isContainedInMap) {
@SuppressWarnings({"unchecked"})
Map<String, Object> mapValue = (Map<String, Object>) field.get(obj);
for (Map.Entry<String, Object> e : mapValue.entrySet()) {
@ -103,6 +105,7 @@ public class DocumentObjectBinder {
Object val = field.get(obj);
if (val == null) return;
if (val instanceof Collection) {
@SuppressWarnings({"rawtypes"})
Collection collection = (Collection) val;
for (Object o : collection) {
SolrInputDocument child = toSolrInputDocument(o);
@ -116,7 +119,7 @@ public class DocumentObjectBinder {
}
}
private List<DocField> getDocFields(Class clazz) {
private List<DocField> getDocFields(@SuppressWarnings({"rawtypes"})Class clazz) {
List<DocField> fields = infocache.get(clazz);
if (fields == null) {
synchronized(infocache) {
@ -127,8 +130,9 @@ public class DocumentObjectBinder {
}
@SuppressForbidden(reason = "Needs access to possibly private @Field annotated fields/methods")
private List<DocField> collectInfo(Class clazz) {
private List<DocField> collectInfo(@SuppressWarnings({"rawtypes"})Class clazz) {
List<DocField> fields = new ArrayList<>();
@SuppressWarnings({"rawtypes"})
Class superClazz = clazz;
List<AccessibleObject> members = new ArrayList<>();
@ -159,6 +163,7 @@ public class DocumentObjectBinder {
private java.lang.reflect.Field field;
private Method setter;
private Method getter;
@SuppressWarnings({"rawtypes"})
private Class type;
private boolean isArray;
private boolean isList;
@ -230,6 +235,7 @@ public class DocumentObjectBinder {
if (field != null) {
type = field.getType();
} else {
@SuppressWarnings({"rawtypes"})
Class[] params = setter.getParameterTypes();
if (params.length != 1) {
throw new BindingException("Invalid setter method (" + setter +
@ -325,7 +331,7 @@ public class DocumentObjectBinder {
* Returns <code>SolrDocument.getFieldValue</code> for regular fields,
* and <code>Map<String, List<Object>></code> for a dynamic field. The key is all matching fieldName's.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
private Object getFieldValue(SolrDocument solrDocument) {
if (child != null) {
List<SolrDocument> children = solrDocument.getChildDocuments();
@ -406,6 +412,7 @@ public class DocumentObjectBinder {
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
<T> void inject(T obj, SolrDocument sdoc) {
Object val = getFieldValue(sdoc);
if(val == null) {

View File

@ -48,7 +48,7 @@ public interface SolrCloudManager extends SolrCloseable {
// Solr-like methods
SolrResponse request(SolrRequest req) throws IOException;
SolrResponse request(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException;
byte[] httpRequest(String url, SolrRequest.METHOD method, Map<String, String> headers, String payload, int timeout, boolean followRedirects) throws IOException;
}

View File

@ -777,13 +777,15 @@ public abstract class BaseCloudSolrClient extends SolrClient {
@SuppressWarnings({"rawtypes"})
public static class RouteResponse<T extends LBSolrClient.Req> extends NamedList {
@SuppressWarnings({"rawtypes"})
private NamedList routeResponses;
private Map<String, T> routes;
public void setRouteResponses(NamedList routeResponses) {
public void setRouteResponses(@SuppressWarnings({"rawtypes"})NamedList routeResponses) {
this.routeResponses = routeResponses;
}
@SuppressWarnings({"rawtypes"})
public NamedList getRouteResponses() {
return routeResponses;
}
@ -1291,6 +1293,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
}
@SuppressWarnings({"unchecked"})
Iterator<Map.Entry<String,Object>> routeIter = routes.iterator();
while (routeIter.hasNext()) {
Map.Entry<String,Object> next = routeIter.next();

View File

@ -226,6 +226,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// Pull from the queue multiple times and streams over a single connection.
// Exits on exception, interruption, or an empty queue to pull from.
//
@SuppressWarnings({"unchecked"})
void sendUpdateStream() throws Exception {
while (!queue.isEmpty()) {

View File

@ -36,26 +36,28 @@ public class ClassificationEvaluation {
}
}
public void putToMap(Map map) {
@SuppressWarnings({"unchecked"})
public void putToMap(@SuppressWarnings({"rawtypes"})Map map) {
map.put("truePositive_i",truePositive);
map.put("trueNegative_i",trueNegative);
map.put("falsePositive_i",falsePositive);
map.put("falseNegative_i",falseNegative);
}
@SuppressWarnings({"rawtypes"})
public Map toMap() {
HashMap map = new HashMap();
putToMap(map);
return map;
}
public static ClassificationEvaluation create(Map map) {
public static ClassificationEvaluation create(@SuppressWarnings({"rawtypes"})Map map) {
ClassificationEvaluation evaluation = new ClassificationEvaluation();
evaluation.addEvaluation(map);
return evaluation;
}
public void addEvaluation(Map map) {
public void addEvaluation(@SuppressWarnings({"rawtypes"})Map map) {
this.truePositive += (long) map.get("truePositive_i");
this.trueNegative += (long) map.get("trueNegative_i");
this.falsePositive += (long) map.get("falsePositive_i");

View File

@ -136,7 +136,7 @@ public class ModelCache {
this.maxSize = maxSize;
}
public boolean removeEldestEntry(Map.Entry eldest) {
public boolean removeEldestEntry(@SuppressWarnings({"rawtypes"})Map.Entry eldest) {
if(size()> maxSize) {
return true;
} else {

View File

@ -52,16 +52,19 @@ public class Tuple implements Cloneable, MapWriter {
* Tuple fields.
* @deprecated use {@link #getFields()} instead of this public field.
*/
@Deprecated
public Map<Object, Object> fields = new HashMap<>(2);
/**
* External serializable field names.
* @deprecated use {@link #getFieldNames()} instead of this public field.
*/
@Deprecated
public List<String> fieldNames;
/**
* Mapping of external field names to internal tuple field names.
* @deprecated use {@link #getFieldLabels()} instead of this public field.
*/
@Deprecated
public Map<String, String> fieldLabels;
public Tuple() {
@ -151,6 +154,7 @@ public class Tuple implements Cloneable, MapWriter {
}
}
@SuppressWarnings({"unchecked"})
public List<Boolean> getBools(Object key) {
return (List<Boolean>) this.fields.get(key);
}
@ -171,6 +175,7 @@ public class Tuple implements Cloneable, MapWriter {
}
}
@SuppressWarnings({"unchecked"})
public List<Date> getDates(Object key) {
List<String> vals = (List<String>) this.fields.get(key);
if (vals == null) return null;
@ -197,14 +202,17 @@ public class Tuple implements Cloneable, MapWriter {
}
}
@SuppressWarnings({"unchecked"})
public List<String> getStrings(Object key) {
return (List<String>)this.fields.get(key);
}
@SuppressWarnings({"unchecked"})
public List<Long> getLongs(Object key) {
return (List<Long>)this.fields.get(key);
}
@SuppressWarnings({"unchecked"})
public List<Double> getDoubles(Object key) {
return (List<Double>)this.fields.get(key);
}
@ -221,6 +229,7 @@ public class Tuple implements Cloneable, MapWriter {
* @deprecated use {@link #getFields()} instead.
*/
@Deprecated(since = "8.6.0")
@SuppressWarnings({"rawtypes"})
public Map getMap() {
return this.fields;
}
@ -252,18 +261,21 @@ public class Tuple implements Cloneable, MapWriter {
this.fieldNames = fieldNames;
}
@SuppressWarnings({"unchecked", "rawtypes"})
public List<Map> getMaps(Object key) {
return (List<Map>) this.fields.get(key);
}
public void setMaps(Object key, List<Map> maps) {
public void setMaps(Object key, @SuppressWarnings({"rawtypes"})List<Map> maps) {
this.fields.put(key, maps);
}
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Map> getMetrics() {
return (Map<String, Map>) this.fields.get(StreamParams.METRICS);
}
@SuppressWarnings({"rawtypes"})
public void setMetrics(Map<String, Map> metrics) {
this.fields.put(StreamParams.METRICS, metrics);
}

View File

@ -108,10 +108,13 @@ public class FieldComparator implements StreamComparator {
* check only once - we can do that in the constructor of this class, create a lambda, and then execute
* that lambda in the compare function. A little bit of branch prediction savings right here.
*/
@SuppressWarnings({"unchecked"})
private void assignComparator(){
if(ComparatorOrder.DESCENDING == order){
comparator = (leftTuple, rightTuple) -> {
@SuppressWarnings({"rawtypes"})
Comparable leftComp = (Comparable)leftTuple.get(leftFieldName);
@SuppressWarnings({"rawtypes"})
Comparable rightComp = (Comparable)rightTuple.get(rightFieldName);
if(leftComp == rightComp){ return 0; } // if both null then they are equal. if both are same ref then are equal
@ -124,7 +127,9 @@ public class FieldComparator implements StreamComparator {
else{
// See above for black magic reasoning.
comparator = (leftTuple, rightTuple) -> {
@SuppressWarnings({"rawtypes"})
Comparable leftComp = (Comparable)leftTuple.get(leftFieldName);
@SuppressWarnings({"rawtypes"})
Comparable rightComp = (Comparable)rightTuple.get(rightFieldName);
if(leftComp == rightComp){ return 0; } // if both null then they are equal. if both are same ref then are equal

View File

@ -73,9 +73,12 @@ public class FieldEqualitor implements StreamEqualitor {
.withExpression(toExpression(factory).toString());
}
@SuppressWarnings({"unchecked"})
public boolean test(Tuple leftTuple, Tuple rightTuple) {
@SuppressWarnings({"rawtypes"})
Comparable leftComp = (Comparable)leftTuple.get(leftFieldName);
@SuppressWarnings({"rawtypes"})
Comparable rightComp = (Comparable)rightTuple.get(rightFieldName);
if(leftComp == rightComp){ return true; } // if both null then they are equal. if both are same ref then are equal

View File

@ -46,6 +46,7 @@ public class GroupOperation implements ReduceOperation {
private UUID operationNodeId = UUID.randomUUID();
private PriorityQueue<Tuple> priorityQueue;
@SuppressWarnings({"rawtypes"})
private Comparator comp;
private StreamComparator streamComparator;
private int size;
@ -75,6 +76,7 @@ public class GroupOperation implements ReduceOperation {
init(streamComparator, size);
}
@SuppressWarnings({"unchecked", "rawtypes"})
private void init(StreamComparator streamComparator, int size) {
this.size = size;
this.streamComparator = streamComparator;
@ -104,14 +106,18 @@ public class GroupOperation implements ReduceOperation {
});
}
@SuppressWarnings({"unchecked"})
public Tuple reduce() {
@SuppressWarnings({"rawtypes"})
LinkedList ll = new LinkedList();
while(priorityQueue.size() > 0) {
ll.addFirst(priorityQueue.poll().getFields());
//This will clear priority queue and so it will be ready for the next group.
}
List<Map> list = new ArrayList(ll);
@SuppressWarnings({"rawtypes"})
List<Map> list = new ArrayList<>(ll);
@SuppressWarnings({"rawtypes"})
Map groupHead = list.get(0);
Tuple tuple = new Tuple(groupHead);
tuple.put("group", list);

View File

@ -35,6 +35,7 @@ class ResultSetMetaDataImpl implements ResultSetMetaData {
this.firstTuple = this.resultSet.getFirstTuple();
}
@SuppressWarnings({"rawtypes"})
private Class getColumnClass(int column) throws SQLException {
Object o = this.firstTuple.get(this.getColumnLabel(column));
if(o == null) {
@ -90,6 +91,7 @@ class ResultSetMetaDataImpl implements ResultSetMetaData {
@Override
public String getColumnLabel(int column) throws SQLException {
@SuppressWarnings({"unchecked"})
Map<String, String> aliases = (Map<String, String>) metadataTuple.get("aliases");
return aliases.get(this.getColumnName(column));
}

View File

@ -249,14 +249,17 @@ public class CollectionApiMapping {
}
Meta(EndPoint endPoint, SolrRequest.METHOD method, CollectionAction action,
String commandName, Map paramsToAttrs) {
String commandName,
@SuppressWarnings({"rawtypes"})Map paramsToAttrs) {
this(endPoint, method, action, commandName, paramsToAttrs, Collections.emptyMap());
}
// lame... the Maps aren't typed simply because callers want to use Utils.makeMap which yields object vals
@SuppressWarnings("unchecked")
Meta(EndPoint endPoint, SolrRequest.METHOD method, CollectionAction action,
String commandName, Map paramsToAttrs, Map prefixParamsToAttrs) {
String commandName,
@SuppressWarnings({"rawtypes"})Map paramsToAttrs,
@SuppressWarnings({"rawtypes"})Map prefixParamsToAttrs) {
this.action = action;
this.commandName = commandName;
this.endPoint = endPoint;
@ -431,6 +434,7 @@ public class CollectionApiMapping {
@SuppressWarnings({"unchecked", "rawtypes"})
private static Collection<String> getParamNames_(CommandOperation op, CommandMeta command) {
Object o = op.getCommandData();
if (o instanceof Map) {
@ -443,6 +447,7 @@ public class CollectionApiMapping {
}
}
@SuppressWarnings({"unchecked"})
public static void collectKeyNames(Map<String, Object> map, List<String> result, String prefix) {
for (Map.Entry<String, Object> e : map.entrySet()) {
if (e.getValue() instanceof Map) {

View File

@ -40,6 +40,7 @@ public abstract class ConfigSetAdminRequest
protected ConfigSetAction action = null;
@SuppressWarnings({"rawtypes"})
protected ConfigSetAdminRequest setAction(ConfigSetAction action) {
this.action = action;
return this;
@ -139,7 +140,7 @@ public abstract class ConfigSetAdminRequest
params.set("baseConfigSet", baseConfigSetName);
}
if (properties != null) {
for (Map.Entry entry : properties.entrySet()) {
for (@SuppressWarnings({"rawtypes"})Map.Entry entry : properties.entrySet()) {
params.set(PROPERTY_PREFIX + "." + entry.getKey().toString(),
entry.getValue().toString());
}

View File

@ -64,8 +64,9 @@ public class CoreApiMapping {
public final CoreAdminAction action;
public final Map<String, String> paramstoAttr;
@SuppressWarnings({"unchecked"})
Meta(EndPoint endPoint, SolrRequest.METHOD method, CoreAdminAction action, String commandName,
Map paramstoAttr) {
@SuppressWarnings({"rawtypes"})Map paramstoAttr) {
this.commandName = commandName;
this.endPoint = endPoint;
this.method = method;

View File

@ -71,8 +71,11 @@ public class JavaBinUpdateRequestCodec {
*
* @throws IOException in case of an exception during marshalling or writing to the stream
*/
@SuppressWarnings({"unchecked"})
public void marshal(UpdateRequest updateRequest, OutputStream os) throws IOException {
@SuppressWarnings({"rawtypes"})
NamedList nl = new NamedList();
@SuppressWarnings({"rawtypes"})
NamedList params = solrParamsToNamedList(updateRequest.getParams());
if (updateRequest.getCommitWithin() != -1) {
params.add("commitWithin", updateRequest.getCommitWithin());
@ -115,6 +118,7 @@ public class JavaBinUpdateRequestCodec {
*
* @throws IOException in case of an exception while reading from the input stream or unmarshalling
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public UpdateRequest unmarshal(InputStream is, final StreamingUpdateHandler handler) throws IOException {
final UpdateRequest updateRequest = new UpdateRequest();
List<List<NamedList>> doclist;
@ -181,6 +185,7 @@ public class JavaBinUpdateRequestCodec {
}
@SuppressWarnings({"rawtypes"})
private NamedList solrParamsToNamedList(SolrParams params) {
if (params == null) return new NamedList();
return params.toNamedList();
@ -204,6 +209,7 @@ public class JavaBinUpdateRequestCodec {
class StreamingCodec extends JavaBinCodec {
@SuppressWarnings({"rawtypes"})
private final NamedList[] namedList;
private final UpdateRequest updateRequest;
private final StreamingUpdateHandler handler;
@ -212,7 +218,7 @@ public class JavaBinUpdateRequestCodec {
// is ever refactored, this will not work.
private boolean seenOuterMostDocIterator;
public StreamingCodec(NamedList[] namedList, UpdateRequest updateRequest, StreamingUpdateHandler handler) {
public StreamingCodec(@SuppressWarnings({"rawtypes"})NamedList[] namedList, UpdateRequest updateRequest, StreamingUpdateHandler handler) {
this.namedList = namedList;
this.updateRequest = updateRequest;
this.handler = handler;
@ -220,11 +226,13 @@ public class JavaBinUpdateRequestCodec {
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected SolrInputDocument createSolrInputDocument(int sz) {
return new MaskCharSequenceSolrInputDoc(new LinkedHashMap(sz));
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public NamedList readNamedList(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
NamedList nl = new NamedList();
@ -239,6 +247,7 @@ public class JavaBinUpdateRequestCodec {
return nl;
}
@SuppressWarnings({"rawtypes"})
private SolrInputDocument listToSolrInputDocument(List<NamedList> namedList) {
SolrInputDocument doc = new SolrInputDocument();
for (int i = 0; i < namedList.size(); i++) {
@ -271,6 +280,7 @@ public class JavaBinUpdateRequestCodec {
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public List readIterator(DataInputInputStream fis) throws IOException {
// default behavior for reading any regular Iterator in the stream
if (seenOuterMostDocIterator) return super.readIterator(fis);
@ -282,6 +292,7 @@ public class JavaBinUpdateRequestCodec {
}
@SuppressWarnings({"unchecked", "rawtypes"})
private List readOuterMostDocIterator(DataInputInputStream fis) throws IOException {
if(namedList[0] == null) namedList[0] = new NamedList();
NamedList params = (NamedList) namedList[0].get("params");
@ -338,11 +349,13 @@ public class JavaBinUpdateRequestCodec {
}
}
private SolrInputDocument convertMapToSolrInputDoc(Map m) {
@SuppressWarnings({"unchecked"})
private SolrInputDocument convertMapToSolrInputDoc(@SuppressWarnings({"rawtypes"})Map m) {
SolrInputDocument result = createSolrInputDocument(m.size());
m.forEach((k, v) -> {
if (CHILDDOC.equals(k.toString())) {
if (v instanceof List) {
@SuppressWarnings({"rawtypes"})
List list = (List) v;
for (Object o : list) {
if (o instanceof Map) {

View File

@ -38,6 +38,7 @@ import static org.apache.solr.common.params.UpdateParams.ASSUME_CONTENT_TYPE;
public class MultiContentWriterRequest extends AbstractUpdateRequest {
@SuppressWarnings({"rawtypes"})
private final Iterator<Pair<NamedList, Object>> payload;
/**
@ -47,7 +48,8 @@ public class MultiContentWriterRequest extends AbstractUpdateRequest {
* @param payload add the per doc params, The Object could be a ByteBuffer or byte[]
*/
public MultiContentWriterRequest(METHOD m, String path, Iterator<Pair<NamedList, Object>> payload) {
public MultiContentWriterRequest(METHOD m, String path,
@SuppressWarnings({"rawtypes"})Iterator<Pair<NamedList, Object>> payload) {
super(m, path);
params = new ModifiableSolrParams();
params.add("multistream", "true");
@ -59,12 +61,15 @@ public class MultiContentWriterRequest extends AbstractUpdateRequest {
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return new RequestWriter.ContentWriter() {
@Override
@SuppressWarnings({"unchecked"})
public void write(OutputStream os) throws IOException {
new JavaBinCodec().marshal((IteratorWriter) iw -> {
while (payload.hasNext()) {
@SuppressWarnings({"rawtypes"})
Pair<NamedList, Object> next = payload.next();
if (next.second() instanceof ByteBuffer || next.second() instanceof byte[]) {
@SuppressWarnings({"rawtypes"})
NamedList params = next.first();
if(params.get(ASSUME_CONTENT_TYPE) == null){
String detectedType = detect(next.second());

View File

@ -52,7 +52,7 @@ public class RequestWriter {
* {@link org.apache.solr.client.solrj.request.RequestWriter#getContentStreams(SolrRequest)} is
* invoked to do a pull write.
*/
public ContentWriter getContentWriter(SolrRequest req) {
public ContentWriter getContentWriter(@SuppressWarnings({"rawtypes"})SolrRequest req) {
if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req;
if (isEmpty(updateRequest)) return null;
@ -77,7 +77,8 @@ public class RequestWriter {
* @deprecated Use {@link #getContentWriter(SolrRequest)}.
*/
@Deprecated
public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
@SuppressWarnings({"unchecked"})
public Collection<ContentStream> getContentStreams(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException {
if (req instanceof UpdateRequest) {
return null;
}
@ -91,11 +92,11 @@ public class RequestWriter {
updateRequest.getDocIterator() == null;
}
public String getPath(SolrRequest req) {
public String getPath(@SuppressWarnings({"rawtypes"})SolrRequest req) {
return req.getPath();
}
public void write(SolrRequest request, OutputStream os) throws IOException {
public void write(@SuppressWarnings({"rawtypes"})SolrRequest request, OutputStream os) throws IOException {
if (request instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) request;
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
@ -129,11 +130,11 @@ public class RequestWriter {
}
}
protected boolean isNull(List l) {
protected boolean isNull(@SuppressWarnings({"rawtypes"})List l) {
return l == null || l.isEmpty();
}
protected boolean isNull(Map l) {
protected boolean isNull(@SuppressWarnings({"rawtypes"})Map l) {
return l == null || l.isEmpty();
}
}

View File

@ -241,7 +241,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
}
private interface ReqSupplier<T extends LBSolrClient.Req> {
T get(SolrRequest solrRequest, List<String> servers);
T get(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, List<String> servers);
}
private <T extends LBSolrClient.Req> Map<String, T> getRoutes(DocRouter router,

View File

@ -38,6 +38,7 @@ public class DomainMap extends HashMap<String, Object> {
put("filter", new ArrayList<String>());
}
@SuppressWarnings({"unchecked"})
final List<String> filterList = (List<String>) get("filter");
filterList.add(filter);
return this;
@ -57,6 +58,7 @@ public class DomainMap extends HashMap<String, Object> {
put("query", new ArrayList<String>());
}
@SuppressWarnings({"unchecked"})
final List<String> queryList = (List<String>) get("query");
queryList.add(query);
return this;
@ -79,6 +81,7 @@ public class DomainMap extends HashMap<String, Object> {
put("excludeTags", new ArrayList<String>());
}
@SuppressWarnings({"unchecked"})
final List<String> excludeTagsList = (List<String>) get("excludeTags");
excludeTagsList.add(excludeTagsValue);
return this;

View File

@ -39,7 +39,8 @@ public class HeatmapFacetMap extends JsonFacetMap<HeatmapFacetMap> {
public HeatmapFacetMap getThis() { return this; }
@Override
public HeatmapFacetMap withSubFacet(String facetName, JsonFacetMap map) {
public HeatmapFacetMap withSubFacet(String facetName,
@SuppressWarnings({"rawtypes"})JsonFacetMap map) {
throw new UnsupportedOperationException(getClass().getName() + " doesn't currently support subfacets");
}

View File

@ -40,11 +40,13 @@ public abstract class JsonFacetMap<B extends JsonFacetMap<B>> extends HashMap<St
return getThis();
}
public B withSubFacet(String facetName, JsonFacetMap map) {
public B withSubFacet(String facetName,
@SuppressWarnings({"rawtypes"})JsonFacetMap map) {
if (! containsKey("facet")) {
put("facet", new HashMap<String, Object>());
}
@SuppressWarnings({"unchecked"})
final Map<String, Object> subFacetMap = (Map<String, Object>) get("facet");
subFacetMap.put(facetName, map);
return getThis();
@ -55,6 +57,7 @@ public abstract class JsonFacetMap<B extends JsonFacetMap<B>> extends HashMap<St
put("facet", new HashMap<String, Object>());
}
@SuppressWarnings({"unchecked"})
final Map<String, Object> subFacetMap = (Map<String, Object>) get("facet");
subFacetMap.put(facetName, statFacet);
return getThis();

View File

@ -165,6 +165,7 @@ public class JsonQueryRequest extends QueryRequest {
jsonRequestMap.put("facet", new HashMap<String, Object>());
}
@SuppressWarnings({"unchecked"})
final Map<String, Object> facetMap = (Map<String, Object>) jsonRequestMap.get("facet");
facetMap.put(facetName, facetJson);
return this;
@ -205,6 +206,7 @@ public class JsonQueryRequest extends QueryRequest {
jsonRequestMap.put("facet", new HashMap<String, Object>());
}
@SuppressWarnings({"unchecked"})
final Map<String, Object> facetMap = (Map<String, Object>) jsonRequestMap.get("facet");
facetMap.put(facetName, facetWriter);
return this;
@ -239,6 +241,7 @@ public class JsonQueryRequest extends QueryRequest {
jsonRequestMap.put("facet", new HashMap<String, Object>());
}
@SuppressWarnings({"unchecked"})
final Map<String, Object> facetMap = (Map<String, Object>) jsonRequestMap.get("facet");
facetMap.put(facetName, facetValue);
return this;
@ -299,6 +302,7 @@ public class JsonQueryRequest extends QueryRequest {
* localparams query (e.g. "{!lucene df=text v='solr'}" )
* @throws IllegalArgumentException if {@code filterQuery} is null
*/
@SuppressWarnings({"unchecked"})
public JsonQueryRequest withFilter(String filterQuery) {
if (filterQuery == null) {
throw new IllegalArgumentException("'filterQuery' must be non-null");
@ -326,6 +330,7 @@ public class JsonQueryRequest extends QueryRequest {
* @param filterQuery a Map of values representing the filter request you wish to send.
* @throws IllegalArgumentException if {@code filterQuery} is null
*/
@SuppressWarnings({"unchecked"})
public JsonQueryRequest withFilter(Map<String, Object> filterQuery) {
if (filterQuery == null) {
throw new IllegalArgumentException("'filterQuery' parameter must be non-null");
@ -343,6 +348,7 @@ public class JsonQueryRequest extends QueryRequest {
*/
public JsonQueryRequest returnFields(String... fieldNames) {
jsonRequestMap.putIfAbsent("fields", new ArrayList<String>());
@SuppressWarnings({"unchecked"})
final List<String> fields = (List<String>) jsonRequestMap.get("fields");
for (String fieldName : fieldNames) {
fields.add(fieldName);
@ -364,6 +370,7 @@ public class JsonQueryRequest extends QueryRequest {
}
jsonRequestMap.putIfAbsent("fields", new ArrayList<String>());
@SuppressWarnings({"unchecked"})
final List<String> fields = (List<String>) jsonRequestMap.get("fields");
for (String fieldName : fieldNames) {
fields.add(fieldName);
@ -387,6 +394,7 @@ public class JsonQueryRequest extends QueryRequest {
*
* @throws IllegalArgumentException if either {@code name} or {@code value} are null
*/
@SuppressWarnings({"unchecked"})
public JsonQueryRequest withParam(String name, Object value) {
if (name == null) {
throw new IllegalArgumentException("'name' parameter must be non-null");

View File

@ -74,6 +74,7 @@ public class AnalysisResponseBase extends SolrResponseBase {
TokenInfo tokenInfo = buildTokenInfoFromString((String) phaseValue);
phase.addTokenInfo(tokenInfo);
} else {
@SuppressWarnings({"unchecked"})
List<NamedList<Object>> tokens = (List<NamedList<Object>>) phaseEntry.getValue();
for (NamedList<Object> token : tokens) {
TokenInfo tokenInfo = buildTokenInfo(token);

View File

@ -83,6 +83,7 @@ public class CollectionAdminResponse extends SolrResponseBase
return Aliases.convertMapOfCommaDelimitedToMapOfList(getAliases());
}
@SuppressWarnings({"unchecked"})
public Map<String, Map<String, String>> getAliasProperties() {
NamedList<Object> response = getResponse();
if (response.get("properties") != null) {

View File

@ -23,12 +23,13 @@ import org.apache.solr.common.util.NamedList;
*/
public class ConfigSetAdminResponse extends SolrResponseBase
{
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked"})
public NamedList<String> getErrorMessages()
{
return (NamedList<String>) getResponse().get( "exceptions" );
}
@SuppressWarnings({"unchecked"})
public static class List extends ConfigSetAdminResponse {
public java.util.List<String> getConfigSets() {
return (java.util.List<String>) getResponse().get("configSets");

View File

@ -40,6 +40,7 @@ public abstract class DelegationTokenResponse extends SolrResponseBase {
*/
public String getDelegationToken() {
try {
@SuppressWarnings({"rawtypes"})
Map map = (Map)getResponse().get("Token");
if (map != null) {
return (String)map.get("urlString");
@ -76,7 +77,9 @@ public abstract class DelegationTokenResponse extends SolrResponseBase {
}
@Override
@SuppressWarnings({"unchecked"})
public NamedList<Object> processResponse(InputStream body, String encoding) {
@SuppressWarnings({"rawtypes"})
Map map = null;
try {
ObjectBuilder builder = new ObjectBuilder(

View File

@ -51,6 +51,7 @@ public class FieldStatsInfo implements Serializable {
Map<Double, Double> percentiles;
@SuppressWarnings({"unchecked"})
public FieldStatsInfo( NamedList<Object> nl, String fname )
{
name = fname;

View File

@ -29,9 +29,11 @@ public class PivotField implements Serializable
final List<PivotField> _pivot;
final Map<String,FieldStatsInfo> _statsInfo;
final Map<String,Integer> _querycounts;
@SuppressWarnings({"rawtypes"})
final List<RangeFacet> _ranges;
public PivotField( String f, Object v, int count, List<PivotField> pivot, Map<String,FieldStatsInfo> statsInfo, Map<String,Integer> queryCounts, List<RangeFacet> ranges)
public PivotField( String f, Object v, int count, List<PivotField> pivot, Map<String,FieldStatsInfo> statsInfo, Map<String,Integer> queryCounts,
@SuppressWarnings({"rawtypes"})List<RangeFacet> ranges)
{
_field = f;
_value = v;
@ -66,6 +68,7 @@ public class PivotField implements Serializable
return _querycounts;
}
@SuppressWarnings({"rawtypes"})
public List<RangeFacet> getFacetRanges() {
return _ranges;
}

View File

@ -43,6 +43,7 @@ public class QueryResponse extends SolrResponseBase
// Direct pointers to known types
private NamedList<Object> _header = null;
private SolrDocumentList _results = null;
@SuppressWarnings({"rawtypes"})
private NamedList<ArrayList> _sortvalues = null;
private NamedList<Object> _facetInfo = null;
private NamedList<Object> _debugInfo = null;
@ -68,6 +69,7 @@ public class QueryResponse extends SolrResponseBase
private List<FacetField> _facetFields = null;
private List<FacetField> _limitingFacets = null;
private List<FacetField> _facetDates = null;
@SuppressWarnings({"rawtypes"})
private List<RangeFacet> _facetRanges = null;
private NamedList<List<PivotField>> _facetPivot = null;
private List<IntervalFacet> _intervalFacets = null;
@ -117,6 +119,7 @@ public class QueryResponse extends SolrResponseBase
}
@Override
@SuppressWarnings({"rawtypes"})
public void setResponse( NamedList<Object> res )
{
super.setResponse( res );
@ -277,6 +280,7 @@ public class QueryResponse extends SolrResponseBase
}
for (Object oGrp : groupsArr) {
@SuppressWarnings({"rawtypes"})
SimpleOrderedMap grpMap = (SimpleOrderedMap) oGrp;
Object sGroupValue = grpMap.get( "groupValue");
SolrDocumentList doclist = (SolrDocumentList) grpMap.get( "doclist");
@ -316,6 +320,7 @@ public class QueryResponse extends SolrResponseBase
}
}
@SuppressWarnings({"rawtypes"})
private void extractFacetInfo( NamedList<Object> info )
{
// Parse the queries
@ -379,6 +384,7 @@ public class QueryResponse extends SolrResponseBase
}
}
@SuppressWarnings({"rawtypes"})
private List<RangeFacet> extractRangeFacets(NamedList<NamedList<Object>> rf) {
List<RangeFacet> facetRanges = new ArrayList<>( rf.size() );
@ -429,6 +435,7 @@ public class QueryResponse extends SolrResponseBase
return facetRanges;
}
@SuppressWarnings({"rawtypes"})
protected List<PivotField> readPivots( List<NamedList> list )
{
ArrayList<PivotField> values = new ArrayList<>( list.size() );
@ -456,7 +463,7 @@ public class QueryResponse extends SolrResponseBase
assert null != val : "Server sent back 'null' for sub pivots?";
assert val instanceof List : "Server sent non-List for sub pivots?";
subPivots = readPivots( (List<NamedList>) val );
subPivots = readPivots( (List<NamedList>) val );
break;
}
case "stats": {
@ -514,6 +521,7 @@ public class QueryResponse extends SolrResponseBase
return _results;
}
@SuppressWarnings({"rawtypes"})
public NamedList<ArrayList> getSortValues(){
return _sortvalues;
}
@ -595,6 +603,7 @@ public class QueryResponse extends SolrResponseBase
return _facetDates;
}
@SuppressWarnings({"rawtypes"})
public List<RangeFacet> getFacetRanges() {
return _facetRanges;
}

View File

@ -107,9 +107,11 @@ public abstract class RangeFacet<B, G> {
private final String value;
private final int count;
@SuppressWarnings({"rawtypes"})
private final RangeFacet rangeFacet;
public Count(String value, int count, RangeFacet rangeFacet) {
public Count(String value, int count,
@SuppressWarnings({"rawtypes"})RangeFacet rangeFacet) {
this.value = value;
this.count = count;
this.rangeFacet = rangeFacet;
@ -123,6 +125,7 @@ public abstract class RangeFacet<B, G> {
return count;
}
@SuppressWarnings({"rawtypes"})
public RangeFacet getRangeFacet() {
return rangeFacet;
}

View File

@ -62,12 +62,14 @@ public class SolrResponseBase extends SolrResponse implements MapWriter
return response.toString();
}
@SuppressWarnings({"rawtypes"})
public NamedList getResponseHeader() {
return (NamedList) response.get("responseHeader");
}
// these two methods are based on the logic in SolrCore.setResponseHeaderValues(...)
public int getStatus() {
@SuppressWarnings({"rawtypes"})
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("status");
@ -78,6 +80,7 @@ public class SolrResponseBase extends SolrResponse implements MapWriter
}
public int getQTime() {
@SuppressWarnings({"rawtypes"})
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("QTime");

View File

@ -145,6 +145,7 @@ public class SpellCheckResponse {
private List<String> alternatives = new ArrayList<>();
private List<Integer> alternativeFrequencies;
@SuppressWarnings({"rawtypes"})
public Suggestion(String token, NamedList<Object> suggestion) {
this.token = token;
for (int i = 0; i < suggestion.size(); i++) {

View File

@ -35,6 +35,7 @@ public class SuggesterResponse {
private final Map<String, List<Suggestion>> suggestionsPerDictionary = new LinkedHashMap<>();
@SuppressWarnings({"unchecked", "rawtypes"})
public SuggesterResponse(Map<String, NamedList<Object>> suggestInfo) {
for (Map.Entry<String, NamedList<Object>> entry : suggestInfo.entrySet()) {
SimpleOrderedMap suggestionsNode = (SimpleOrderedMap) entry.getValue().getVal(0);

View File

@ -49,6 +49,7 @@ public class BucketBasedJsonFacet {
private long afterLastBucketCount = UNSET_FLAG;
private long betweenAllBucketsCount = UNSET_FLAG;
@SuppressWarnings({"unchecked", "rawtypes"})
public BucketBasedJsonFacet(NamedList<Object> bucketBasedFacet) {
for (Map.Entry<String, Object> entry : bucketBasedFacet) {
final String key = entry.getKey();

View File

@ -44,6 +44,7 @@ public class HeatmapJsonFacet {
private List<List<Integer>> countGrid;
private String countEncodedAsBase64PNG;
@SuppressWarnings({"unchecked"})
public HeatmapJsonFacet(NamedList<Object> heatmapNL) {
gridLevel = (int) heatmapNL.get("gridLevel");
columns = (int) heatmapNL.get("columns");

View File

@ -56,6 +56,7 @@ public class NestableJsonFacet {
// Stat/agg facet value
statsByName.put(key, entry.getValue());
} else if(entry.getValue() instanceof NamedList) { // Either heatmap/query/range/terms facet
@SuppressWarnings({"unchecked"})
final NamedList<Object> facet = (NamedList<Object>) entry.getValue();
final boolean isBucketBased = facet.get("buckets") != null;
final boolean isHeatmap = HeatmapJsonFacet.isHeatmapFacet(facet);

View File

@ -132,7 +132,8 @@ public class SchemaResponse extends SolrResponseBase {
}
}
private static SchemaRepresentation createSchemaConfiguration(Map schemaObj) {
private static SchemaRepresentation createSchemaConfiguration(
@SuppressWarnings({"rawtypes"})Map schemaObj) {
SchemaRepresentation schemaRepresentation = new SchemaRepresentation();
schemaRepresentation.setName(getSchemaName(schemaObj));
schemaRepresentation.setVersion(getSchemaVersion(schemaObj));
@ -145,19 +146,24 @@ public class SchemaResponse extends SolrResponseBase {
return schemaRepresentation;
}
private static String getSchemaName(Map schemaNamedList) {
private static String getSchemaName(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
return (String) schemaNamedList.get("name");
}
private static Float getSchemaVersion(Map schemaNamedList) {
private static Float getSchemaVersion(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
return (Float) schemaNamedList.get("version");
}
private static String getSchemaUniqueKey(Map schemaNamedList) {
private static String getSchemaUniqueKey(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
return (String) schemaNamedList.get("uniqueKey");
}
private static Map<String, Object> getSimilarity(Map schemaNamedList) {
private static Map<String, Object> getSimilarity(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
@SuppressWarnings({"unchecked"})
NamedList<Object> similarityNamedList = (NamedList<Object>) schemaNamedList.get("similarity");
Map<String, Object> similarity = null;
if (similarityNamedList != null) similarity = extractAttributeMap(similarityNamedList);
@ -165,7 +171,8 @@ public class SchemaResponse extends SolrResponseBase {
}
@SuppressWarnings("unchecked")
private static List<Map<String, Object>> getFields(Map schemaNamedList) {
private static List<Map<String, Object>> getFields(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
List<Map<String, Object>> fieldsAttributes = new LinkedList<>();
List<NamedList<Object>> fieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("fields");
for (NamedList<Object> fieldNamedList : fieldsResponse) {
@ -177,7 +184,8 @@ public class SchemaResponse extends SolrResponseBase {
}
@SuppressWarnings("unchecked")
private static List<Map<String, Object>> getDynamicFields(Map schemaNamedList) {
private static List<Map<String, Object>> getDynamicFields(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
List<Map<String, Object>> dynamicFieldsAttributes = new LinkedList<>();
List<NamedList<Object>> dynamicFieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("dynamicFields");
for (NamedList<Object> fieldNamedList : dynamicFieldsResponse) {
@ -189,7 +197,8 @@ public class SchemaResponse extends SolrResponseBase {
}
@SuppressWarnings("unchecked")
private static List<Map<String, Object>> getCopyFields(Map schemaNamedList) {
private static List<Map<String, Object>> getCopyFields(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
List<Map<String, Object>> copyFieldsAttributes = new LinkedList<>();
List<NamedList<Object>> copyFieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("copyFields");
for (NamedList<Object> copyFieldNamedList : copyFieldsResponse) {
@ -201,7 +210,8 @@ public class SchemaResponse extends SolrResponseBase {
}
@SuppressWarnings("unchecked")
private static List<FieldTypeDefinition> getFieldTypeDefinitions(Map schemaNamedList) {
private static List<FieldTypeDefinition> getFieldTypeDefinitions(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
List<FieldTypeDefinition> fieldTypeDefinitions = new LinkedList<>();
List<NamedList<Object>> fieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("fieldTypes");
for (NamedList<Object> fieldNamedList : fieldsResponse) {
@ -213,7 +223,8 @@ public class SchemaResponse extends SolrResponseBase {
}
@SuppressWarnings("unchecked")
private static List<FieldTypeRepresentation> getFieldTypeRepresentations(Map schemaNamedList) {
private static List<FieldTypeRepresentation> getFieldTypeRepresentations(
@SuppressWarnings({"rawtypes"})Map schemaNamedList) {
List<FieldTypeRepresentation> fieldTypeRepresentations = new LinkedList<>();
List<NamedList<Object>> fieldsResponse = (List<NamedList<Object>>) schemaNamedList.get("fieldTypes");
for (NamedList<Object> fieldNamedList : fieldsResponse) {
@ -229,6 +240,7 @@ public class SchemaResponse extends SolrResponseBase {
public void setResponse(NamedList<Object> response) {
super.setResponse(response);
@SuppressWarnings({"rawtypes"})
Map schemaObj = (Map) response.get("schema");
schemaRepresentation = createSchemaConfiguration(schemaObj);
}

View File

@ -63,6 +63,7 @@ public class ClientUtils
//------------------------------------------------------------------------
//------------------------------------------------------------------------
@SuppressWarnings({"unchecked"})
public static void writeXML( SolrInputDocument doc, Writer writer ) throws IOException
{
writer.write("<doc>");
@ -81,6 +82,7 @@ public class ClientUtils
update = entry.getKey().toString();
v = entry.getValue();
if (v instanceof Collection) {
@SuppressWarnings({"rawtypes"})
Collection values = (Collection) v;
for (Object value : values) {
writeVal(writer, name, value, update);

View File

@ -42,12 +42,14 @@ public class LinkedHashMapWriter<V> extends LinkedHashMap<String, V> implements
}
@Override
@SuppressWarnings({"unchecked"})
public Object _get(String path, Object def) {
if (path.indexOf('/') == -1) return getOrDefault(path, (V) def);
return MapWriter.super._get(path, def);
}
@Override
@SuppressWarnings({"unchecked"})
public Object _get(List<String> path, Object def) {
if (path.size() == 1) return getOrDefault(path.get(0), (V) def);
return MapWriter.super._get(path, def);

View File

@ -99,8 +99,8 @@ public class SolrDocument extends SolrDocumentBase<Object, SolrDocument> impleme
* set multiple fields with the included contents. This will replace any existing
* field with the given name
*/
@SuppressWarnings("unchecked")
public void setField(String name, Object value)
@SuppressWarnings({"unchecked", "rawtypes"})
public void setField(String name, Object value)
{
if( value instanceof Object[] ) {
value = new ArrayList(Arrays.asList( (Object[])value ));
@ -186,6 +186,7 @@ public class SolrDocument extends SolrDocumentBase<Object, SolrDocument> impleme
public Object getFirstValue(String name) {
Object v = _fields.get( name );
if (v == null || !(v instanceof Collection)) return v;
@SuppressWarnings({"rawtypes"})
Collection c = (Collection)v;
if (c.size() > 0 ) {
return c.iterator().next();

View File

@ -108,7 +108,8 @@ public class SolrInputField implements Iterable<Object>, Serializable
public Object getFirstValue() {
if (value instanceof Collection) {
Collection c = (Collection<Object>) value;
@SuppressWarnings({"unchecked"})
Collection<Object> c = (Collection<Object>) value;
if (c.size() > 0) {
return c.iterator().next();
}
@ -200,6 +201,7 @@ public class SolrInputField implements Iterable<Object>, Serializable
SolrInputField clone = new SolrInputField(name);
// We can't clone here, so we rely on simple primitives
if (value instanceof Collection) {
@SuppressWarnings({"unchecked"})
Collection<Object> values = (Collection<Object>) value;
Collection<Object> cloneValues = new ArrayList<>(values.size());
cloneValues.addAll(values);

View File

@ -80,7 +80,7 @@ public class Aliases {
* @param zNodeVersion the version of the data in zookeeper that this instance corresponds to
* @return A new immutable Aliases object
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
public static Aliases fromJSON(byte[] bytes, int zNodeVersion) {
Map<String, Map> aliasMap;
if (bytes == null || bytes.length == 0) {
@ -89,6 +89,7 @@ public class Aliases {
aliasMap = (Map<String, Map>) Utils.fromJSON(bytes);
}
@SuppressWarnings({"rawtypes"})
Map colAliases = aliasMap.getOrDefault(COLLECTION, Collections.emptyMap());
colAliases = convertMapOfCommaDelimitedToMapOfList(colAliases); // also unmodifiable
@ -106,6 +107,7 @@ public class Aliases {
assert collectionAliasProperties.isEmpty();
return null;
} else {
@SuppressWarnings({"rawtypes"})
Map<String,Map> tmp = new LinkedHashMap<>();
tmp.put(COLLECTION, convertMapOfListToMapOfCommaDelimited(collectionAliases));
if (!collectionAliasProperties.isEmpty()) {

View File

@ -219,6 +219,7 @@ public class ClusterState implements JSONWriter.Writable {
if (bytes == null || bytes.length == 0) {
return new ClusterState(liveNodes, Collections.<String, DocCollection>emptyMap());
}
@SuppressWarnings({"unchecked"})
Map<String, Object> stateMap = (Map<String, Object>) Utils.fromJSON(bytes);
return createFromCollectionMap(version, stateMap, liveNodes);
}
@ -227,6 +228,7 @@ public class ClusterState implements JSONWriter.Writable {
Map<String,CollectionRef> collections = new LinkedHashMap<>(stateMap.size());
for (Entry<String, Object> entry : stateMap.entrySet()) {
String collectionName = entry.getKey();
@SuppressWarnings({"unchecked"})
DocCollection coll = collectionFromObjects(collectionName, (Map<String,Object>)entry.getValue(), version);
collections.put(collectionName, new CollectionRef(coll));
}
@ -239,6 +241,7 @@ public class ClusterState implements JSONWriter.Writable {
Map<String,Object> props;
Map<String,Slice> slices;
@SuppressWarnings({"unchecked"})
Map<String, Object> sliceObjs = (Map<String, Object>) objs.get(DocCollection.SHARDS);
if (sliceObjs == null) {
// legacy format from 4.0... there was no separate "shards" level to contain the collection shards.
@ -258,6 +261,7 @@ public class ClusterState implements JSONWriter.Writable {
// back compat with Solr4.4
router = DocRouter.getDocRouter((String)routerObj);
} else {
@SuppressWarnings({"rawtypes"})
Map routerProps = (Map)routerObj;
router = DocRouter.getDocRouter((String) routerProps.get("name"));
}

View File

@ -188,6 +188,7 @@ public class CompositeIdRouter extends HashBasedRouter {
}
@Override
@SuppressWarnings({"unchecked"})
public List<Range> partitionRange(int partitions, Range range) {
int min = range.min;
int max = range.max;

View File

@ -46,6 +46,7 @@ import static org.apache.solr.common.util.Utils.toJSONString;
/**
* Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
*/
@SuppressWarnings({"overrides"})
public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
public static final String DOC_ROUTER = "router";
@ -382,6 +383,11 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
return super.equals(that) && Objects.equals(this.name, other.name) && this.znodeVersion == other.znodeVersion;
}
// @Override
// public int hashCode() {
// throw new UnsupportedOperationException("TODO unimplemented DocCollection.hashCode");
// }
/**
* @return the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#NRT} this collection was created with
*/

View File

@ -50,6 +50,7 @@ public abstract class DocRouter {
public String getRouteField(DocCollection coll) {
if (coll == null) return null;
@SuppressWarnings({"rawtypes"})
Map m = (Map) coll.get(DOC_ROUTER);
if (m == null) return null;
return (String) m.get("field");
@ -169,6 +170,7 @@ public abstract class DocRouter {
* of variation in resulting ranges - odd ranges will be larger and even ranges will be smaller
* by up to that percentage.
*/
@SuppressWarnings({"unchecked"})
public List<Range> partitionRange(int partitions, Range range, float fuzz) {
int min = range.min;
int max = range.max;

View File

@ -22,7 +22,7 @@ import java.util.Objects;
import java.util.Set;
import org.apache.solr.common.util.Utils;
@SuppressWarnings({"overrides"})
public class Replica extends ZkNodeProps {
/**
@ -153,7 +153,10 @@ public class Replica extends ZkNodeProps {
return name.equals(replica.name);
}
// @Override
// public int hashCode() {
// throw new UnsupportedOperationException("TODO unimplemented Replica.hashCode()");
// }
/** Also known as coreNodeName. */
public String getName() {
return name;

View File

@ -40,6 +40,7 @@ public class Slice extends ZkNodeProps implements Iterable<Replica> {
public final String collection;
/** Loads multiple slices into a Map from a generic Map that probably came from deserialized JSON. */
@SuppressWarnings({"unchecked"})
public static Map<String,Slice> loadAllFromMap(String collection, Map<String, Object> genericSlices) {
if (genericSlices == null) return Collections.emptyMap();
Map<String, Slice> result = new LinkedHashMap<>(genericSlices.size());
@ -129,6 +130,7 @@ public class Slice extends ZkNodeProps implements Iterable<Replica> {
* @param replicas The replicas of the slice. This is used directly and a copy is not made. If null, replicas will be constructed from props.
* @param props The properties of the slice - a shallow copy will always be made.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public Slice(String name, Map<String,Replica> replicas, Map<String,Object> props, String collection) {
super( props==null ? new LinkedHashMap<String,Object>(2) : new LinkedHashMap<>(props));
this.name = name;
@ -188,6 +190,7 @@ public class Slice extends ZkNodeProps implements Iterable<Replica> {
}
@SuppressWarnings({"unchecked"})
private Map<String,Replica> makeReplicas(String collection, String slice,Map<String,Object> genericReplicas) {
if (genericReplicas == null) return new HashMap<>(1);
Map<String,Replica> result = new LinkedHashMap<>(genericReplicas.size());

View File

@ -31,6 +31,7 @@ import static org.apache.solr.common.util.Utils.toJSONString;
/**
* ZkNodeProps contains generic immutable properties.
*/
@SuppressWarnings({"overrides"})
public class ZkNodeProps implements JSONWriter.Writable {
protected final Map<String,Object> propMap;
@ -91,6 +92,7 @@ public class ZkNodeProps implements JSONWriter.Writable {
/**
* Create Replica from json string that is typically stored in zookeeper.
*/
@SuppressWarnings({"unchecked"})
public static ZkNodeProps load(byte[] bytes) {
Map<String, Object> props = null;
if (bytes[0] == 2) {
@ -169,4 +171,8 @@ public class ZkNodeProps implements JSONWriter.Writable {
public boolean equals(Object that) {
return that instanceof ZkNodeProps && ((ZkNodeProps)that).propMap.equals(this.propMap);
}
// @Override
// public int hashCode() {
// throw new UnsupportedOperationException("TODO unimplemented ZkNodeProps.hashCode");
// }
}

View File

@ -96,6 +96,7 @@ public class ImplicitSnitch extends Snitch {
}
private void fillRole(String solrNode, SnitchContext ctx, String key) throws KeeperException, InterruptedException {
@SuppressWarnings({"rawtypes"})
Map roles = (Map) ctx.retrieve(ZkStateReader.ROLES); // we don't want to hit the ZK for each node
// so cache and reuse
try {
@ -106,10 +107,12 @@ public class ImplicitSnitch extends Snitch {
}
}
private void cacheRoles(String solrNode, SnitchContext ctx, String key, Map roles) {
private void cacheRoles(String solrNode, SnitchContext ctx, String key,
@SuppressWarnings({"rawtypes"})Map roles) {
ctx.store(ZkStateReader.ROLES, roles);
if (roles != null) {
for (Object o : roles.entrySet()) {
@SuppressWarnings({"rawtypes"})
Map.Entry e = (Map.Entry) o;
if (e.getValue() instanceof List) {
if (((List) e.getValue()).contains(solrNode)) {

View File

@ -23,6 +23,7 @@ import java.util.Set;
*
*/
public abstract class Snitch {
@SuppressWarnings({"rawtypes"})
public static final Set<Class> WELL_KNOWN_SNITCHES = Collections.singleton(ImplicitSnitch.class);
public abstract void getTags(String solrNode, Set<String> requestedTags, SnitchContext ctx);

View File

@ -64,6 +64,7 @@ public abstract class SnitchContext implements RemoteCallback {
return Collections.emptyMap();
}
@SuppressWarnings({"rawtypes"})
public abstract Map getZkJson(String path) throws KeeperException, InterruptedException;
public String getNode() {

View File

@ -70,6 +70,7 @@ public class CommandOperation {
commandData = o;
}
@SuppressWarnings({"unchecked"})
public Map<String, Object> getDataMap() {
if (commandData instanceof Map) {
//noinspection unchecked
@ -100,6 +101,7 @@ public class CommandOperation {
return commandData;
}
if (commandData instanceof Map) {
@SuppressWarnings({"rawtypes"})
Map metaData = (Map) commandData;
return metaData.get(key);
} else {
@ -170,6 +172,7 @@ public class CommandOperation {
return s;
}
@SuppressWarnings({"rawtypes"})
private Map errorDetails() {
return Utils.makeMap(name, commandData, ERR_MSGS, errors);
}
@ -207,6 +210,7 @@ public class CommandOperation {
public static final String ERR_MSGS = "errorMessages";
public static final String ROOT_OBJ = "";
@SuppressWarnings({"rawtypes"})
public static List<Map> captureErrors(List<CommandOperation> ops) {
List<Map> errors = new ArrayList<>();
for (CommandOperation op : ops) {
@ -226,6 +230,7 @@ public class CommandOperation {
* Parse the command operations into command objects from javabin payload
* * @param singletonCommands commands that cannot be repeated
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static List<CommandOperation> parse(InputStream in, Set<String> singletonCommands) throws IOException {
List<CommandOperation> operations = new ArrayList<>();
@ -288,6 +293,7 @@ public class CommandOperation {
ev = parser.nextEvent();
Object val = ob.getVal();
if (val instanceof List && !singletonCommands.contains(key)) {
@SuppressWarnings({"rawtypes"})
List list = (List) val;
for (Object o : list) {
if (!(o instanceof Map)) {
@ -308,6 +314,7 @@ public class CommandOperation {
return new CommandOperation(name, commandData);
}
@SuppressWarnings({"rawtypes"})
public Map getMap(String key, Map def) {
Object o = getMapVal(key);
if (o == null) return def;
@ -325,7 +332,8 @@ public class CommandOperation {
return new String(toJSON(singletonMap(name, commandData)), StandardCharsets.UTF_8);
}
public static List<CommandOperation> readCommands(Iterable<ContentStream> streams, NamedList resp) throws IOException {
public static List<CommandOperation> readCommands(Iterable<ContentStream> streams,
@SuppressWarnings({"rawtypes"})NamedList resp) throws IOException {
return readCommands(streams, resp, Collections.emptySet());
}
@ -339,7 +347,9 @@ public class CommandOperation {
* @return parsed list of commands
* @throws IOException if there is an error while parsing the stream
*/
public static List<CommandOperation> readCommands(Iterable<ContentStream> streams, NamedList resp, Set<String> singletonCommands)
@SuppressWarnings({"unchecked"})
public static List<CommandOperation> readCommands(Iterable<ContentStream> streams,
@SuppressWarnings({"rawtypes"})NamedList resp, Set<String> singletonCommands)
throws IOException {
if (streams == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream");
@ -353,6 +363,7 @@ public class CommandOperation {
ops.addAll(parse(stream.getReader(), singletonCommands));
}
}
@SuppressWarnings({"rawtypes"})
List<Map> errList = CommandOperation.captureErrors(ops);
if (!errList.isEmpty()) {
resp.add(CommandOperation.ERR_MSGS, errList);

View File

@ -313,7 +313,8 @@ public abstract class ContentStreamBase implements ContentStream
public void setSourceInfo(String sourceInfo) {
this.sourceInfo = sourceInfo;
}
public static ContentStream create(RequestWriter requestWriter, SolrRequest req) throws IOException {
public static ContentStream create(RequestWriter requestWriter,
@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
RequestWriter.ContentWriter contentWriter = requestWriter.getContentWriter(req);
contentWriter.write(baos);

View File

@ -184,9 +184,11 @@ public class ExecutorUtil {
final String submitterContextStr = ctxStr.length() <= MAX_THREAD_NAME_LEN ? ctxStr : ctxStr.substring(0, MAX_THREAD_NAME_LEN);
final Exception submitterStackTrace = enableSubmitterStackTrace ? new Exception("Submitter stack trace") : null;
final List<InheritableThreadLocalProvider> providersCopy = providers;
@SuppressWarnings({"rawtypes"})
final ArrayList<AtomicReference> ctx = providersCopy.isEmpty() ? null : new ArrayList<>(providersCopy.size());
if (ctx != null) {
for (int i = 0; i < providers.size(); i++) {
@SuppressWarnings({"rawtypes"})
AtomicReference reference = new AtomicReference();
ctx.add(reference);
providersCopy.get(i).store(reference);

View File

@ -239,6 +239,7 @@ public class Hash {
/** Returns the MurmurHash3_x86_32 hash.
* Original source/tests at https://github.com/yonik/java_util/
*/
@SuppressWarnings({"fallthrough"})
public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) {
final int c1 = 0xcc9e2d51;
@ -456,6 +457,7 @@ public class Hash {
/** Returns the MurmurHash3_x64_128 hash, placing the result in "out". */
@SuppressWarnings({"fallthrough"})
public static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed, LongPair out) {
// The original algorithm does have a 32 bit unsigned seed.
// We have to mask to match the behavior of the unsigned types and prevent sign extension.

View File

@ -117,6 +117,7 @@ public class JsonRecordReader {
* @param r the stream reader
* @return results a List of emitted records
*/
@SuppressWarnings({"unchecked"})
public List<Map<String, Object>> getAllRecords(Reader r) throws IOException {
final List<Map<String, Object>> results = new ArrayList<>();
// Deep copy is required here because the stream might hold on to the map
@ -342,6 +343,7 @@ public class JsonRecordReader {
}
@Override
@SuppressWarnings({"unchecked"})
public void walk(int event) throws IOException {
if (event == OBJECT_START) {
walkObject();
@ -352,6 +354,7 @@ public class JsonRecordReader {
// ensure that the value is of type List
final Object val = values.get(name);
if (val != null && !(val instanceof List)) {
@SuppressWarnings({"rawtypes"})
final ArrayList listVal = new ArrayList(1);
listVal.add(val);
values.put(name, listVal);
@ -446,6 +449,7 @@ public class JsonRecordReader {
}
}
@SuppressWarnings({"unchecked"})
private void addChildDoc2ParentDoc(Map<String, Object> record, Map<String, Object> values, String key) {
record = Utils.getDeepCopy(record, 2);
Object oldVal = values.get(key);
@ -454,6 +458,7 @@ public class JsonRecordReader {
} else if (oldVal instanceof List) {
((List) oldVal).add(record);
} else {
@SuppressWarnings({"rawtypes"})
ArrayList l = new ArrayList();
l.add(oldVal);
l.add(record);
@ -476,6 +481,7 @@ public class JsonRecordReader {
}
@SuppressWarnings({"unchecked"})
private void putValue(Map<String, Object> values, String fieldName, Object o) {
if (o == null) return;
Object val = values.get(fieldName);
@ -484,10 +490,12 @@ public class JsonRecordReader {
return;
}
if (val instanceof List) {
@SuppressWarnings({"rawtypes"})
List list = (List) val;
list.add(o);
return;
}
@SuppressWarnings({"rawtypes"})
ArrayList l = new ArrayList();
l.add(val);
l.add(o);
@ -602,9 +610,11 @@ public class JsonRecordReader {
public abstract void walk(int event) throws IOException;
}
@SuppressWarnings({"unchecked"})
public static List<Object> parseArrayFieldValue(int ev, JSONParser parser, MethodFrameWrapper runnable) throws IOException {
assert ev == ARRAY_START;
@SuppressWarnings({"rawtypes"})
ArrayList lst = new ArrayList(2);
for (; ; ) {
ev = parser.nextEvent();

View File

@ -36,6 +36,7 @@ import org.apache.solr.common.annotation.JsonProperty;
*/
public class JsonSchemaCreator {
@SuppressWarnings({"rawtypes"})
public static final Map<Class, String> natives = new HashMap<>();
static {
@ -67,7 +68,7 @@ public class JsonSchemaCreator {
return map;
}
private static void createObjectSchema(Class klas, Map<String, Object> map) {
private static void createObjectSchema(@SuppressWarnings({"rawtypes"})Class klas, Map<String, Object> map) {
map.put("type", "object");
Map<String, Object> props = new HashMap<>();
map.put("properties", props);

View File

@ -37,11 +37,12 @@ public class RetryUtil {
boolean execute();
}
public static void retryOnThrowable(Class clazz, long timeoutms, long intervalms, RetryCmd cmd) throws Throwable {
public static void retryOnThrowable(@SuppressWarnings({"rawtypes"})Class clazz, long timeoutms, long intervalms, RetryCmd cmd) throws Throwable {
retryOnThrowable(Collections.singleton(clazz), timeoutms, intervalms, cmd);
}
public static void retryOnThrowable(Set<Class> classes, long timeoutms, long intervalms, RetryCmd cmd) throws Throwable {
public static void retryOnThrowable(@SuppressWarnings({"rawtypes"})Set<Class> classes,
long timeoutms, long intervalms, RetryCmd cmd) throws Throwable {
long timeout = System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutms, TimeUnit.MILLISECONDS);
while (true) {
try {
@ -61,8 +62,8 @@ public class RetryUtil {
}
}
private static boolean isInstanceOf(Set<Class> classes, Throwable t) {
for (Class c : classes) {
private static boolean isInstanceOf(@SuppressWarnings({"rawtypes"})Set<Class> classes, Throwable t) {
for (@SuppressWarnings({"rawtypes"})Class c : classes) {
if (c.isInstance(t)) {
return true;
}

View File

@ -40,6 +40,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableSet;
@SuppressWarnings({"overrides"})
public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
private static final String INCLUDE = "#include";
@ -347,6 +348,11 @@ public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
return that instanceof Map && this.delegate.equals(that);
}
// @Override
// public int hashCode() {
// throw new UnsupportedOperationException("TODO unimplemented ValidatingJsonMap.hashCode");
// }
@SuppressWarnings({"unchecked"})
public static final ValidatingJsonMap EMPTY = new ValidatingJsonMap(Collections.EMPTY_MAP);