From 6801d4c13982b42007ec6d1ea1f443902e2fb438 Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Fri, 12 Jun 2020 20:06:16 -0400 Subject: [PATCH] SOLR-14565: Fix or suppress warnings in solrj/impl and solrj/io/graph --- solr/CHANGES.txt | 2 + .../solrj/impl/BaseCloudSolrClient.java | 17 ++++++-- .../impl/BaseHttpClusterStateProvider.java | 4 +- .../client/solrj/impl/BaseHttpSolrClient.java | 6 ++- .../solrj/impl/BinaryRequestWriter.java | 6 +-- .../solrj/impl/BinaryResponseParser.java | 1 + .../client/solrj/impl/CloudSolrClient.java | 2 +- .../solrj/impl/ClusterStateProvider.java | 2 + .../impl/ConcurrentUpdateHttp2SolrClient.java | 3 +- .../impl/ConcurrentUpdateSolrClient.java | 3 +- .../impl/DelegationTokenHttpSolrClient.java | 2 +- .../solrj/impl/Http2ClusterStateProvider.java | 1 + .../client/solrj/impl/Http2SolrClient.java | 22 ++++++----- .../solrj/impl/HttpClusterStateProvider.java | 1 + .../client/solrj/impl/HttpSolrClient.java | 26 ++++++++----- .../solrj/impl/Krb5HttpClientBuilder.java | 1 + .../client/solrj/impl/LBHttpSolrClient.java | 4 +- .../solr/client/solrj/impl/LBSolrClient.java | 15 ++++--- .../solrj/impl/SolrClientCloudManager.java | 2 +- .../impl/SolrClientNodeStateProvider.java | 4 ++ .../impl/StreamingBinaryResponseParser.java | 3 ++ .../impl/ZkClientClusterStateProvider.java | 1 + .../solrj/impl/ZkDistribStateManager.java | 1 + .../solrj/io/graph/GatherNodesStream.java | 39 +++++++++++-------- .../solr/client/solrj/io/graph/Node.java | 4 +- .../solrj/io/graph/ShortestPathStream.java | 21 +++++----- .../solr/client/solrj/io/graph/Traversal.java | 11 +++--- .../solrj/io/graph/TraversalIterator.java | 9 +++-- .../solrj/response/HealthCheckResponse.java | 1 + 29 files changed, 133 insertions(+), 81 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 430ed529868..78fd23405ea 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -336,6 +336,8 @@ Other Changes * SOLR-14563: Fix or suppress warnings in solr/contrib (Erick Erickson) +* SOLR-14565: Fix or suppress warnings in solrj/impl and solrj/io/graph (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/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java index 6f1223fb5ce..fa9d2c11cdd 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java @@ -463,6 +463,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { assertZKStateProvider().zkStateReader.registerDocCollectionWatcher(collection, watcher); } + @SuppressWarnings({"unchecked"}) private NamedList directUpdate(AbstractUpdateRequest request, String collection) throws SolrServerException { UpdateRequest updateRequest = (UpdateRequest) request; SolrParams params = request.getParams(); @@ -522,6 +523,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { } final NamedList exceptions = new NamedList<>(); + @SuppressWarnings({"rawtypes"}) final NamedList shardResponses = new NamedList<>(routes.size()+1); // +1 for deleteQuery long start = System.nanoTime(); @@ -612,6 +614,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { long end = System.nanoTime(); + @SuppressWarnings({"rawtypes"}) RouteResponse rr = condenseResponse(shardResponses, (int) TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS)); rr.setRouteResponses(shardResponses); rr.setRoutes(routes); @@ -670,6 +673,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { return urlMap; } + @SuppressWarnings({"unchecked", "rawtypes"}) protected T condenseResponse(NamedList response, int timeMillis, Supplier supplier) { T condensed = supplier.get(); int status = 0; @@ -766,10 +770,12 @@ public abstract class BaseCloudSolrClient extends SolrClient { return condensed; } + @SuppressWarnings({"rawtypes"}) public RouteResponse condenseResponse(NamedList response, int timeMillis) { return condenseResponse(response, timeMillis, RouteResponse::new); } + @SuppressWarnings({"rawtypes"}) public static class RouteResponse extends NamedList { private NamedList routeResponses; private Map routes; @@ -829,7 +835,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { } @Override - public NamedList request(SolrRequest request, String collection) throws SolrServerException, IOException { + public NamedList request(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws SolrServerException, IOException { // the collection parameter of the request overrides that of the parameter to this method String requestCollection = request.getCollection(); if (requestCollection != null) { @@ -847,7 +853,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { * there's a chance that the request will fail due to cached stale state, * which means the state must be refreshed from ZK and retried. */ - protected NamedList requestWithRetryOnStaleState(SolrRequest request, int retryCount, List inputCollections) + protected NamedList requestWithRetryOnStaleState(@SuppressWarnings({"rawtypes"})SolrRequest request, int retryCount, List inputCollections) throws SolrServerException, IOException { connect(); // important to call this before you start working with the ZkStateReader @@ -911,8 +917,10 @@ public abstract class BaseCloudSolrClient extends SolrClient { if(o != null && o instanceof Map) { //remove this because no one else needs this and tests would fail if they are comparing responses resp.remove(resp.size()-1); + @SuppressWarnings({"rawtypes"}) Map invalidStates = (Map) o; for (Object invalidEntries : invalidStates.entrySet()) { + @SuppressWarnings({"rawtypes"}) Map.Entry e = (Map.Entry) invalidEntries; getDocCollection((String) e.getKey(), (Integer) e.getValue()); } @@ -1030,7 +1038,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { return resp; } - protected NamedList sendRequest(SolrRequest request, List inputCollections) + protected NamedList sendRequest(@SuppressWarnings({"rawtypes"})SolrRequest request, List inputCollections) throws SolrServerException, IOException { connect(); @@ -1205,6 +1213,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { //it is readily available just return it return ref.get(); } + @SuppressWarnings({"rawtypes"}) List locks = this.locks; final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size())); DocCollection fetchedCol = null; @@ -1262,7 +1271,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { * the replication factor that was achieved in each shard involved in the request. * For single doc updates, there will be only one shard in the return value. */ - @SuppressWarnings("rawtypes") + @SuppressWarnings({"unchecked", "rawtypes"}) public Map getShardReplicationFactor(String collection, NamedList resp) { connect(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java index 8ed7854ff9b..55fa3b5aea5 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java @@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory; import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.*; +@SuppressWarnings({"unchecked"}) public abstract class BaseHttpClusterStateProvider implements ClusterStateProvider { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -108,7 +109,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid + " solrUrl(s) or zkHost(s)."); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({"rawtypes"}) private ClusterState fetchClusterState(SolrClient client, String collection, Map clusterProperties) throws SolrServerException, IOException, NotACollectionException { ModifiableSolrParams params = new ModifiableSolrParams(); if (collection != null) { @@ -179,6 +180,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid } } + @SuppressWarnings({"rawtypes"}) private static Set fetchLiveNodes(SolrClient client) throws Exception { ModifiableSolrParams params = new ModifiableSolrParams(); params.set("action", "CLUSTERSTATUS"); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java index 96443201f07..6a5edc96d65 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java @@ -49,15 +49,16 @@ public abstract class BaseHttpSolrClient extends SolrClient { * it sends a proper payload back to the client */ public static class RemoteExecutionException extends RemoteSolrException { + @SuppressWarnings({"rawtypes"}) private NamedList meta; - public RemoteExecutionException(String remoteHost, int code, String msg, NamedList meta) { + public RemoteExecutionException(String remoteHost, int code, String msg, @SuppressWarnings({"rawtypes"})NamedList meta) { super(remoteHost, code, msg, null); this.meta = meta; } - public static RemoteExecutionException create(String host, NamedList errResponse) { + public static RemoteExecutionException create(String host, @SuppressWarnings({"rawtypes"})NamedList errResponse) { Object errObj = errResponse.get("error"); if (errObj != null) { Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code")); @@ -71,6 +72,7 @@ public abstract class BaseHttpSolrClient extends SolrClient { } + @SuppressWarnings({"rawtypes"}) public NamedList getMetaData() { return meta; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java index 542c876f0c9..9906ddf4cc2 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java @@ -39,7 +39,7 @@ import static org.apache.solr.common.params.CommonParams.JAVABIN_MIME; public class BinaryRequestWriter extends RequestWriter { @Override - 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; @@ -60,7 +60,7 @@ public class BinaryRequestWriter extends RequestWriter { } @Override - public Collection getContentStreams(SolrRequest req) throws IOException { + public Collection getContentStreams(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException { if (req instanceof UpdateRequest) { UpdateRequest updateRequest = (UpdateRequest) req; if (isEmpty(updateRequest) ) return null; @@ -77,7 +77,7 @@ public class BinaryRequestWriter extends RequestWriter { } @Override - 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; new JavaBinUpdateRequestCodec().marshal(updateRequest, os); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java index e033abb12a7..b146dcd9ee8 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java @@ -45,6 +45,7 @@ public class BinaryResponseParser extends ResponseParser { } @Override + @SuppressWarnings({"unchecked"}) public NamedList processResponse(InputStream body, String encoding) { try { return (NamedList) createCodec().unmarshal(body); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java index 24748caba5f..cb9e7c2e80c 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java @@ -135,7 +135,7 @@ public class CloudSolrClient extends BaseCloudSolrClient { * @deprecated since Solr 8.0 */ @Deprecated - public RouteResponse condenseResponse(NamedList response, int timeMillis) { + public RouteResponse condenseResponse(@SuppressWarnings({"rawtypes"})NamedList response, int timeMillis) { return condenseResponse(response, timeMillis, RouteResponse::new); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java index a7ce278e2c0..fcd9e29e9f0 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java @@ -89,6 +89,7 @@ public interface ClusterStateProvider extends SolrCloseable { * Obtain a cluster property, or the default value if it doesn't exist. */ default T getClusterProperty(String key, T defaultValue) { + @SuppressWarnings({"unchecked"}) T value = (T) getClusterProperties().get(key); if (value == null) return defaultValue; @@ -98,6 +99,7 @@ public interface ClusterStateProvider extends SolrCloseable { /** * Obtain a cluster property, or null if it doesn't exist. */ + @SuppressWarnings({"unchecked"}) default T getClusterProperty(String propertyName) { return (T) getClusterProperties().get(propertyName); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java index 0883e7fe048..a1334cbf1c3 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java @@ -209,6 +209,7 @@ public class ConcurrentUpdateHttp2SolrClient 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 { try { @@ -345,7 +346,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient { } @Override - public NamedList request(final SolrRequest request, String collection) + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws SolrServerException, IOException { if (!(request instanceof UpdateRequest)) { request.setBasePath(basePath); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java index c95cbd7991b..b3bbcc2bfaa 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java @@ -171,6 +171,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient { /** * Opens a connection and sends everything... */ + @SuppressWarnings({"unchecked"}) class Runner implements Runnable { volatile Thread thread = null; volatile boolean inPoll = false; @@ -481,7 +482,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient { } @Override - public NamedList request(final SolrRequest request, String collection) + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws SolrServerException, IOException { if (!(request instanceof UpdateRequest)) { return client.request(request, collection); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java index 1b51f3bd6f2..25792aed65b 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java @@ -88,7 +88,7 @@ public class DelegationTokenHttpSolrClient extends HttpSolrClient { } @Override - protected HttpRequestBase createMethod(final SolrRequest request, String collection) throws IOException, SolrServerException { + protected HttpRequestBase createMethod(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws IOException, SolrServerException { SolrParams params = request.getParams(); if (params != null && params.getParams(DELEGATION_TOKEN_PARAM) != null) { throw new IllegalArgumentException(DELEGATION_TOKEN_PARAM + " parameter not supported"); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java index 335684a4df5..1f801c98075 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.solr.client.solrj.SolrClient; +@SuppressWarnings({"unchecked"}) public class Http2ClusterStateProvider extends BaseHttpClusterStateProvider { final Http2SolrClient httpClient; final boolean closeClient; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java index 9e46a96d6ca..a8b7207a22e 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java @@ -244,7 +244,7 @@ public class Http2SolrClient extends SolrClient { assert ObjectReleaseTracker.release(this); } - public boolean isV2ApiRequest(final SolrRequest request) { + public boolean isV2ApiRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request) { return request instanceof V2Request || request.getPath().contains("/____v2"); } @@ -268,7 +268,7 @@ public class Http2SolrClient extends SolrClient { this.isXml = isXml; } - boolean belongToThisStream(SolrRequest solrRequest, String collection) { + boolean belongToThisStream(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) { ModifiableSolrParams solrParams = new ModifiableSolrParams(solrRequest.getParams()); if (!origParams.toNamedList().equals(solrParams.toNamedList()) || !StringUtils.equals(origCollection, collection)) { return false; @@ -336,7 +336,7 @@ public class Http2SolrClient extends SolrClient { return outStream; } - public void send(OutStream outStream, SolrRequest req, String collection) throws IOException { + public void send(OutStream outStream, @SuppressWarnings({"rawtypes"})SolrRequest req, String collection) throws IOException { assert outStream.belongToThisStream(req, collection); this.requestWriter.write(req, outStream.outProvider.getOutputStream()); if (outStream.isXml) { @@ -361,7 +361,7 @@ public class Http2SolrClient extends SolrClient { outStream.flush(); } - public NamedList request(SolrRequest solrRequest, + public NamedList request(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection, OnComplete onComplete) throws IOException, SolrServerException { Request req = makeRequest(solrRequest, collection); @@ -436,7 +436,7 @@ public class Http2SolrClient extends SolrClient { return StringUtils.isEmpty(contentType)? null : ContentType.parse(contentType); } - private void setBasicAuthHeader(SolrRequest solrRequest, Request req) { + private void setBasicAuthHeader(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, Request req) { if (solrRequest.getBasicAuthUser() != null && solrRequest.getBasicAuthPassword() != null) { String userPass = solrRequest.getBasicAuthUser() + ":" + solrRequest.getBasicAuthPassword(); String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET)); @@ -444,14 +444,14 @@ public class Http2SolrClient extends SolrClient { } } - private Request makeRequest(SolrRequest solrRequest, String collection) + private Request makeRequest(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) throws SolrServerException, IOException { Request req = createRequest(solrRequest, collection); decorateRequest(req, solrRequest); return req; } - private void decorateRequest(Request req, SolrRequest solrRequest) { + private void decorateRequest(Request req, @SuppressWarnings({"rawtypes"})SolrRequest solrRequest) { req.header(HttpHeader.ACCEPT_ENCODING, null); if (solrRequest.getUserPrincipal() != null) { req.attribute(REQ_PRINCIPAL_KEY, solrRequest.getUserPrincipal()); @@ -465,6 +465,7 @@ public class Http2SolrClient extends SolrClient { req.onComplete(listener); } + @SuppressWarnings({"unchecked"}) Map headers = solrRequest.getHeaders(); if (headers != null) { for (Map.Entry entry : headers.entrySet()) { @@ -479,7 +480,8 @@ public class Http2SolrClient extends SolrClient { return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString(); } - private Request createRequest(SolrRequest solrRequest, String collection) throws IOException, SolrServerException { + @SuppressWarnings({"unchecked"}) + private Request createRequest(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) throws IOException, SolrServerException { if (solrRequest.getBasePath() == null && serverBaseUrl == null) throw new IllegalArgumentException("Destination node is not provided!"); @@ -630,7 +632,7 @@ public class Http2SolrClient extends SolrClient { return processor == null || processor instanceof InputStreamResponseParser; } - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"unchecked", "rawtypes"}) private NamedList processErrorsAndResponse(Response response, final ResponseParser processor, InputStream is, @@ -749,7 +751,7 @@ public class Http2SolrClient extends SolrClient { } @Override - public NamedList request(SolrRequest request, String collection) throws SolrServerException, IOException { + public NamedList request(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws SolrServerException, IOException { return request(request, collection, null); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java index 07fd8f826ba..947e4e7b010 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.http.client.HttpClient; import org.apache.solr.client.solrj.SolrClient; +@SuppressWarnings({"unchecked"}) public class HttpClusterStateProvider extends BaseHttpClusterStateProvider { private final HttpClient httpClient; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java index a7348318f36..78106295e19 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java @@ -239,7 +239,7 @@ public class HttpSolrClient extends BaseHttpSolrClient { * org.apache.solr.client.solrj.ResponseParser) */ @Override - public NamedList request(final SolrRequest request, String collection) + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws SolrServerException, IOException { ResponseParser responseParser = request.getResponseParser(); if (responseParser == null) { @@ -248,15 +248,16 @@ public class HttpSolrClient extends BaseHttpSolrClient { return request(request, responseParser, collection); } - public NamedList request(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { return request(request, processor, null); } - public NamedList request(final SolrRequest request, final ResponseParser processor, String collection) + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor, String collection) throws SolrServerException, IOException { HttpRequestBase method = createMethod(request, collection); setBasicAuthHeader(request, method); if (request.getHeaders() != null) { + @SuppressWarnings({"unchecked"}) Map headers = request.getHeaders(); for (Map.Entry entry : headers.entrySet()) { method.setHeader(entry.getKey(), entry.getValue()); @@ -265,11 +266,11 @@ public class HttpSolrClient extends BaseHttpSolrClient { return executeMethod(method, request.getUserPrincipal(), processor, isV2ApiRequest(request)); } - private boolean isV2ApiRequest(final SolrRequest request) { + private boolean isV2ApiRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request) { return request instanceof V2Request || request.getPath().contains("/____v2"); } - private void setBasicAuthHeader(SolrRequest request, HttpRequestBase method) throws UnsupportedEncodingException { + private void setBasicAuthHeader(@SuppressWarnings({"rawtypes"})SolrRequest request, HttpRequestBase method) throws UnsupportedEncodingException { if (request.getBasicAuthUser() != null && request.getBasicAuthPassword() != null) { String userPass = request.getBasicAuthUser() + ":" + request.getBasicAuthPassword(); String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET)); @@ -288,7 +289,7 @@ public class HttpSolrClient extends BaseHttpSolrClient { /** * @lucene.experimental */ - public HttpUriRequestResponse httpUriRequest(final SolrRequest request) + public HttpUriRequestResponse httpUriRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request) throws SolrServerException, IOException { ResponseParser responseParser = request.getResponseParser(); if (responseParser == null) { @@ -300,7 +301,7 @@ public class HttpSolrClient extends BaseHttpSolrClient { /** * @lucene.experimental */ - public HttpUriRequestResponse httpUriRequest(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { + public HttpUriRequestResponse httpUriRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { HttpUriRequestResponse mrr = new HttpUriRequestResponse(); final HttpRequestBase method = createMethod(request, null); ExecutorService pool = ExecutorUtil.newMDCAwareFixedThreadPool(1, new SolrNamedThreadFactory("httpUriRequest")); @@ -340,7 +341,8 @@ public class HttpSolrClient extends BaseHttpSolrClient { return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString(); } - protected HttpRequestBase createMethod(SolrRequest request, String collection) throws IOException, SolrServerException { + @SuppressWarnings({"unchecked"}) + protected HttpRequestBase createMethod(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws IOException, SolrServerException { if (request instanceof V2RequestSupport) { request = ((V2RequestSupport) request).getV2Request(); } @@ -474,7 +476,11 @@ public class HttpSolrClient extends BaseHttpSolrClient { } - private HttpEntityEnclosingRequestBase fillContentStream(SolrRequest request, Collection streams, ModifiableSolrParams wparams, boolean isMultipart, LinkedList postOrPutParams, String fullQueryUrl) throws IOException { + private HttpEntityEnclosingRequestBase fillContentStream( + @SuppressWarnings({"rawtypes"})SolrRequest request, + Collection streams, ModifiableSolrParams wparams, + boolean isMultipart, LinkedList postOrPutParams, + String fullQueryUrl) throws IOException { HttpEntityEnclosingRequestBase postOrPut = SolrRequest.METHOD.POST == request.getMethod() ? new HttpPost(fullQueryUrl) : new HttpPut(fullQueryUrl); @@ -533,7 +539,7 @@ public class HttpSolrClient extends BaseHttpSolrClient { private static final List errPath = Arrays.asList("metadata", "error-class");//Utils.getObjectByPath(err, false,"metadata/error-class") - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"unchecked", "rawtypes"}) protected NamedList executeMethod(HttpRequestBase method, Principal userPrincipal, final ResponseParser processor, final boolean isV2Api) throws SolrServerException { method.addHeader("User-Agent", AGENT); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java index a6b12177519..6c4b44a24ca 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java @@ -208,6 +208,7 @@ public class Krb5HttpClientBuilder implements HttpClientBuilderFactory { private javax.security.auth.login.Configuration baseConfig; // the com.sun.security.jgss appNames + @SuppressWarnings({"unchecked", "rawtypes"}) private Set initiateAppNames = new HashSet( Arrays.asList("com.sun.security.jgss.krb5.initiate", "com.sun.security.jgss.initiate")); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java index 63add2c5f56..bc4efbbf9f4 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java @@ -80,11 +80,11 @@ public class LBHttpSolrClient extends LBSolrClient { */ @Deprecated public static class Req extends LBSolrClient.Req { - public Req(SolrRequest request, List servers) { + public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List servers) { super(request, servers); } - public Req(SolrRequest request, List servers, Integer numServersToTry) { + public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List servers, Integer numServersToTry) { super(request, servers, numServersToTry); } } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java index 176f07d32af..1654e32a595 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java @@ -138,22 +138,24 @@ public abstract class LBSolrClient extends SolrClient { public static class Req { + @SuppressWarnings({"rawtypes"}) protected SolrRequest request; protected List servers; protected int numDeadServersToTry; private final Integer numServersToTry; - public Req(SolrRequest request, List servers) { + public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List servers) { this(request, servers, null); } - public Req(SolrRequest request, List servers, Integer numServersToTry) { + public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List servers, Integer numServersToTry) { this.request = request; this.servers = servers; this.numDeadServersToTry = servers.size(); this.numServersToTry = numServersToTry; } + @SuppressWarnings({"rawtypes"}) public SolrRequest getRequest() { return request; } @@ -349,7 +351,7 @@ public abstract class LBSolrClient extends SolrClient { /** * @return time allowed in nanos, returns -1 if no time_allowed is specified. */ - private long getTimeAllowedInNanos(final SolrRequest req) { + private long getTimeAllowedInNanos(@SuppressWarnings({"rawtypes"})final SolrRequest req) { SolrParams reqParams = req.getParams(); return reqParams == null ? -1 : TimeUnit.NANOSECONDS.convert(reqParams.getInt(CommonParams.TIME_ALLOWED, -1), TimeUnit.MILLISECONDS); @@ -576,12 +578,12 @@ public abstract class LBSolrClient extends SolrClient { * @throws IOException If there is a low-level I/O error. */ @Override - public NamedList request(final SolrRequest request, String collection) + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws SolrServerException, IOException { return request(request, collection, null); } - public NamedList request(final SolrRequest request, String collection, + public NamedList request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection, final Integer numServersToTry) throws SolrServerException, IOException { Exception ex = null; ServerWrapper[] serverList = aliveServerList; @@ -678,7 +680,8 @@ public abstract class LBSolrClient extends SolrClient { * @param request the request will be sent to the picked server * @return the picked server */ - protected ServerWrapper pickServer(ServerWrapper[] aliveServerList, SolrRequest request) { + protected ServerWrapper pickServer(ServerWrapper[] aliveServerList, + @SuppressWarnings({"rawtypes"})SolrRequest request) { int count = counter.incrementAndGet() & Integer.MAX_VALUE; return aliveServerList[count % aliveServerList.length]; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java index 7aacd42f719..5ad7ff49272 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java @@ -124,7 +124,7 @@ public class SolrClientCloudManager implements SolrCloudManager { } @Override - public SolrResponse request(SolrRequest req) throws IOException { + public SolrResponse request(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException { try { return req.process(solrClient); } catch (SolrServerException e) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java index 796207a56f9..1b394eec64c 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java @@ -78,6 +78,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter private final CloudSolrClient solrClient; protected final Map>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); private Map snitchSession = new HashMap<>(); + @SuppressWarnings({"rawtypes"}) private Map nodeVsTags = new HashMap<>(); private Map withCollectionsMap = new HashMap<>(); @@ -147,6 +148,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter @Override public Map>> getReplicaInfo(String node, Collection keys) { + @SuppressWarnings({"unchecked"}) Map>> result = nodeVsCollectionVsShardVsReplicaInfo.computeIfAbsent(node, Utils.NEW_HASHMAP_FUN); if (!keys.isEmpty()) { Map> metricsKeyVsTagReplica = new HashMap<>(); @@ -197,6 +199,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter metricsKeyVsTag.forEach((key, tag) -> { Object v = Utils.getObjectByPath(rsp.nl, true, Arrays.asList("metrics", key)); if (tag instanceof Function) { + @SuppressWarnings({"unchecked"}) Pair p = (Pair) ((Function) tag).apply(v); ctx.getTags().put(p.first(), p.second()); } else { @@ -334,6 +337,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter @Override + @SuppressWarnings({"rawtypes"}) public Map getZkJson(String path) throws KeeperException, InterruptedException { return Utils.getJson(zkClientClusterStateProvider.getZkStateReader().getZkClient(), path, true); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java index 5c41f6b81a0..75609090e6a 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java @@ -101,6 +101,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser { EntryImpl entry = (EntryImpl) e; if( !entry.type().isContainer) return; if (e.isKeyValEntry() && entry.getTag() == Tag._SOLRDOCLST) { + @SuppressWarnings({"rawtypes"}) List l = (List) e.metadata(); e.listenContainer(fastCallback.initDocList( (Long) l.get(0), @@ -120,6 +121,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser { private EntryListener docListener; + @SuppressWarnings({"unchecked"}) private NamedList streamDocs(InputStream body) { try (JavaBinCodec codec = new JavaBinCodec() { @@ -143,6 +145,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser { @Override public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException { SolrDocumentList solrDocs = new SolrDocumentList(); + @SuppressWarnings({"rawtypes"}) List list = (List) readVal(dis); solrDocs.setNumFound((Long) list.get(0)); solrDocs.setStart((Long) list.get(1)); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java index 407349613e3..3020c1aced5 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java @@ -36,6 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@SuppressWarnings({"unchecked"}) public class ZkClientClusterStateProvider implements ClusterStateProvider { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java index e2834db0476..b15445b75ec 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java @@ -181,6 +181,7 @@ public class ZkDistribStateManager implements DistribStateManager { } @Override + @SuppressWarnings({"unchecked"}) public AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws InterruptedException, IOException { Map map = new HashMap<>(); Stat stat = new Stat(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java index 702d03486eb..bd1c5c60e71 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java @@ -82,7 +82,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { String traverseFrom, String traverseTo, String gather, - Map queryParams, + @SuppressWarnings({"rawtypes"})Map queryParams, List metrics, boolean trackTraversal, Set scatter, @@ -115,7 +115,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { } - Set scatter = new HashSet(); + Set scatter = new HashSet<>(); StreamExpressionNamedParameter scatterExpression = factory.getNamedOperand(expression, "scatter"); @@ -169,7 +169,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { } String[] rootNodes = fields[0].split(","); - List l = new ArrayList(); + List l = new ArrayList<>(); for(String n : rootNodes) { l.add(n.trim()); } @@ -181,7 +181,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { } List metricExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, Metric.class); - List metrics = new ArrayList(); + List metrics = new ArrayList<>(); for(int idx = 0; idx < metricExpressions.size(); ++idx){ metrics.add(factory.constructMetric(metricExpressions.get(idx))); } @@ -245,13 +245,14 @@ public class GatherNodesStream extends TupleStream implements Expressible { docFreq); } + @SuppressWarnings({"unchecked"}) private void init(String zkHost, String collection, TupleStream tupleStream, String traverseFrom, String traverseTo, String gather, - Map queryParams, + @SuppressWarnings({"rawtypes"})Map queryParams, List metrics, boolean trackTraversal, Set scatter, @@ -295,7 +296,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { Set> entries = queryParams.entrySet(); // parameters - for(Map.Entry param : entries){ + for(@SuppressWarnings({"rawtypes"})Map.Entry param : entries){ String value = param.getValue().toString(); // SOLR-8409: This is a special case where the params contain a " character @@ -400,7 +401,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { } public List children() { - List l = new ArrayList(); + List l = new ArrayList<>(); l.add(tupleStream); return l; } @@ -409,10 +410,11 @@ public class GatherNodesStream extends TupleStream implements Expressible { tupleStream.open(); } + @SuppressWarnings({"unchecked"}) private class JoinRunner implements Callable> { private List nodes; - private List edges = new ArrayList(); + private List edges = new ArrayList<>(); public JoinRunner(List nodes) { this.nodes = nodes; @@ -421,7 +423,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { public List call() { - Set flSet = new HashSet(); + Set flSet = new HashSet<>(); flSet.add(gather); flSet.add(traverseTo); @@ -508,24 +510,26 @@ public class GatherNodesStream extends TupleStream implements Expressible { tupleStream.close(); } + @SuppressWarnings({"unchecked"}) public Tuple read() throws IOException { if (out == null) { - List joinBatch = new ArrayList(); - List>> futures = new ArrayList(); - Map level = new HashMap(); + List joinBatch = new ArrayList<>(); + List>> futures = new ArrayList<>(); + Map level = new HashMap<>(); ExecutorService threadPool = null; try { threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(4, new SolrNamedThreadFactory("GatherNodesStream")); - Map roots = new HashMap(); + Map roots = new HashMap<>(); while (true) { Tuple tuple = tupleStream.read(); if (tuple.EOF) { if (joinBatch.size() > 0) { JoinRunner joinRunner = new JoinRunner(joinBatch); + @SuppressWarnings({"rawtypes"}) Future future = threadPool.submit(joinRunner); futures.add(future); } @@ -541,7 +545,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { if(!roots.containsKey(key)) { Node node = new Node(value, trackTraversal); if (metrics != null) { - List _metrics = new ArrayList(); + List _metrics = new ArrayList<>(); for (Metric metric : metrics) { _metrics.add(metric.newInstance()); } @@ -557,9 +561,10 @@ public class GatherNodesStream extends TupleStream implements Expressible { joinBatch.add(value); if (joinBatch.size() == 400) { JoinRunner joinRunner = new JoinRunner(joinBatch); + @SuppressWarnings({"rawtypes"}) Future future = threadPool.submit(joinRunner); futures.add(future); - joinBatch = new ArrayList(); + joinBatch = new ArrayList<>(); } } @@ -588,7 +593,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { } else { node = new Node(_gather, trackTraversal); if (metrics != null) { - List _metrics = new ArrayList(); + List _metrics = new ArrayList<>(); for (Metric metric : metrics) { _metrics.add(metric.newInstance()); } @@ -638,7 +643,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { public void open() {this.it = ids.iterator();} public void close() {} public StreamComparator getStreamSort() {return null;} - public List children() {return new ArrayList();} + public List children() {return new ArrayList<>();} public void setStreamContext(StreamContext context) {} public Tuple read() { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Node.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Node.java index 7c99f75758f..6b551d784d8 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Node.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Node.java @@ -30,7 +30,7 @@ public class Node { public Node(String id, boolean track) { this.id=id; if(track) { - ancestors = new HashSet(); + ancestors = new HashSet<>(); } } @@ -62,7 +62,7 @@ public class Node { List cols = traversal.getCollections(); if(ancestors != null) { - List l = new ArrayList(); + List l = new ArrayList<>(); for(String ancestor : ancestors) { String[] ancestorParts = ancestor.split("\\^"); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java index 9d12e48df34..6f2b8bd4026 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java @@ -68,7 +68,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { private int maxDepth; private String zkHost; private String collection; - private LinkedList shortestPaths = new LinkedList(); + private LinkedList shortestPaths = new LinkedList<>(); private boolean found; private StreamContext streamContext; private int threads; @@ -282,20 +282,21 @@ public class ShortestPathStream extends TupleStream implements Expressible { } public List children() { - List l = new ArrayList(); + List l = new ArrayList<>(); return l; } + @SuppressWarnings({"unchecked", "rawtypes"}) public void open() throws IOException { - List>> allVisited = new ArrayList(); + List>> allVisited = new ArrayList<>(); Map visited = new HashMap(); visited.put(this.fromNode, null); allVisited.add(visited); int depth = 0; Map> nextVisited = null; - List targets = new ArrayList(); + List targets = new ArrayList<>(); ExecutorService threadPool = null; try { @@ -309,8 +310,8 @@ public class ShortestPathStream extends TupleStream implements Expressible { Iterator it = nodes.iterator(); nextVisited = new HashMap(); int batchCount = 0; - List queryNodes = new ArrayList(); - List futures = new ArrayList(); + List queryNodes = new ArrayList<>(); + List futures = new ArrayList<>(); JOIN: //Queue up all the batches while (it.hasNext()) { @@ -343,7 +344,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { List parents = nextVisited.get(edge.to); parents.add(edge.from); } else { - List parents = new ArrayList(); + List parents = new ArrayList<>(); parents.add(edge.from); nextVisited.put(edge.to, parents); } @@ -353,7 +354,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { List parents = nextVisited.get(edge.to); parents.add(edge.from); } else { - List parents = new ArrayList(); + List parents = new ArrayList<>(); parents.add(edge.from); nextVisited.put(edge.to, parents); } @@ -376,7 +377,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { Set finalPaths = new HashSet(); if(targets.size() > 0) { for(Edge edge : targets) { - List paths = new ArrayList(); + List paths = new ArrayList<>(); LinkedList path = new LinkedList(); path.addFirst(edge.to); paths.add(path); @@ -415,7 +416,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { private class JoinRunner implements Callable> { private List nodes; - private List edges = new ArrayList(); + private List edges = new ArrayList<>(); public JoinRunner(List nodes) { this.nodes = nodes; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Traversal.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Traversal.java index 43d23b33b19..e5afd4d8a62 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Traversal.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/Traversal.java @@ -22,11 +22,11 @@ import java.util.*; public class Traversal { - private List> graph = new ArrayList(); - private List fields = new ArrayList(); - private List collections = new ArrayList(); - private Set scatter = new HashSet(); - private Set collectionSet = new HashSet(); + private List> graph = new ArrayList<>(); + private List fields = new ArrayList<>(); + private List collections = new ArrayList<>(); + private Set scatter = new HashSet<>(); + private Set collectionSet = new HashSet<>(); private boolean trackTraversal; private int depth; @@ -90,6 +90,7 @@ public class Traversal { LEAVES; } + @SuppressWarnings({"unchecked"}) public Iterator iterator() { return new TraversalIterator(this, scatter); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/TraversalIterator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/TraversalIterator.java index 7cfe3756fb7..e2df8d51b6f 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/TraversalIterator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/TraversalIterator.java @@ -26,6 +26,7 @@ import java.util.Set; import org.apache.solr.client.solrj.io.Tuple; import org.apache.solr.client.solrj.io.graph.Traversal.Scatter; +@SuppressWarnings({"rawtypes"}) class TraversalIterator implements Iterator { private List> graph; @@ -49,10 +50,10 @@ class TraversalIterator implements Iterator { collections = traversal.getCollections(); fields = traversal.getFields(); - List outCollections = new ArrayList(); - List outFields = new ArrayList(); - List levelNums = new ArrayList(); - List> levelIterators = new ArrayList(); + List outCollections = new ArrayList<>(); + List outFields = new ArrayList<>(); + List levelNums = new ArrayList<>(); + List> levelIterators = new ArrayList<>(); if(scatter.contains(Scatter.BRANCHES)) { if(graph.size() > 1) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/HealthCheckResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/HealthCheckResponse.java index b6fc36bb6b7..0b4d4bcceea 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/HealthCheckResponse.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/HealthCheckResponse.java @@ -24,6 +24,7 @@ public class HealthCheckResponse extends SolrResponseBase { public HealthCheckResponse() { } + @SuppressWarnings({"unchecked"}) public NamedList getErrorMessages() { return (NamedList) getResponse().get( "errors" ); }