SOLR-14563: Fix or suppress warnings in solr/contrib

This commit is contained in:
Erick Erickson 2020-06-12 10:56:22 -04:00
parent 26075fc1dc
commit 8cbfb192ab
24 changed files with 52 additions and 17 deletions

View File

@ -334,6 +334,8 @@ Other Changes
* SOLR-14559: Fix or suppress warnings in solr/core/src/java/org/apache/solr/util,
response, cloud, security, schema, api (Erick Erickson)
* SOLR-14563: Fix or suppress warnings in solr/contrib (Erick Erickson)
================== 8.5.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -215,7 +215,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
@SuppressWarnings("unchecked")
@Override
public void init(NamedList args) {
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
// high level (loose) check for which type of config we have.
//
@ -260,7 +260,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
* "source" and "dest" init params do <em>not</em> exist.
*/
@SuppressWarnings("unchecked")
private void initSimpleRegexReplacement(NamedList args) {
private void initSimpleRegexReplacement(@SuppressWarnings({"rawtypes"})NamedList args) {
// The syntactic sugar for the case where there is only one regex pattern for source and the same pattern
// is used for the destination pattern...
//
@ -316,7 +316,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
* "source" and "dest" init params <em>do</em> exist.
*/
@SuppressWarnings("unchecked")
private void initSourceSelectorSyntax(NamedList args) {
private void initSourceSelectorSyntax(@SuppressWarnings({"rawtypes"})NamedList args) {
// Full and complete syntax where source and dest are mandatory.
//
// source may be a single string or a selector.
@ -340,6 +340,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
if (1 == sources.size()) {
if (sources.get(0) instanceof NamedList) {
// nested set of selector options
@SuppressWarnings({"rawtypes"})
NamedList selectorConfig = (NamedList) args.remove(SOURCE_PARAM);
srcInclusions = parseSelectorParams(selectorConfig);
@ -355,6 +356,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
throw new SolrException(SERVER_ERROR, "Init param '" + SOURCE_PARAM +
"' child 'exclude' must be <lst/>");
}
@SuppressWarnings({"rawtypes"})
NamedList exc = (NamedList) excObj;
srcExclusions.add(parseSelectorParams(exc));
if (0 < exc.size()) {
@ -387,6 +389,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
}
if (d instanceof NamedList) {
@SuppressWarnings({"rawtypes"})
NamedList destList = (NamedList) d;
Object patt = destList.remove(PATTERN_PARAM);
@ -571,7 +574,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory
}
/** macro */
private static SelectorParams parseSelectorParams(NamedList args) {
private static SelectorParams parseSelectorParams(@SuppressWarnings({"rawtypes"})NamedList args) {
return FieldMutatingUpdateProcessorFactory.parseSelectorParams(args);
}
}

View File

@ -101,7 +101,7 @@ public class DecimalNumericConversionFunction {
public static class RoundFunction {
public static final String name = "round";
public static final CreatorFunction creatorFunction = (params -> {
return DecimalNumericConversionFunction.createDecimalConversionFunction(name, val -> (int)Math.round(val), val -> (long)Math.round(val), params);
return DecimalNumericConversionFunction.createDecimalConversionFunction(name, val -> Math.round(val), val -> Math.round(val), params);
});
}

View File

@ -131,7 +131,7 @@ public class ReplaceFunction {
return new StringStreamReplaceFunction((StringValueStream)baseExpr,(StringValue)compExpr,(StringValue)fillExpr);
}
if (baseExpr instanceof AnalyticsValue) {
return new ValueReplaceFunction((AnalyticsValue)baseExpr,(AnalyticsValue)compExpr,(AnalyticsValue)fillExpr);
return new ValueReplaceFunction((AnalyticsValue)baseExpr,compExpr,fillExpr);
}
return new StreamReplaceFunction(baseExpr,compExpr,fillExpr);

View File

@ -36,7 +36,7 @@ public class AnalyticsComponent extends SearchComponent {
public static final String COMPONENT_NAME = "analytics";
@Override
public void init(NamedList args) {
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
AnalyticsRequestParser.init();
}

View File

@ -55,7 +55,7 @@ public class AnalyticsShardResponseWriter implements BinaryQueryResponseWriter {
}
@Override
public void init(NamedList args) {}
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {}
/**
* Manages the streaming of analytics reduction data if no exception occurred.

View File

@ -132,6 +132,7 @@ public class ExtractingDocumentLoader extends ContentStreamLoader {
}
@Override
@SuppressWarnings({"unchecked"})
public void load(SolrQueryRequest req, SolrQueryResponse rsp,
ContentStream stream, UpdateRequestProcessor processor) throws Exception {
Parser parser = null;
@ -243,6 +244,7 @@ public class ExtractingDocumentLoader extends ContentStreamLoader {
rsp.add(stream.getName(), writer.toString());
writer.close();
String[] names = metadata.names();
@SuppressWarnings({"rawtypes"})
NamedList metadataNL = new NamedList();
for (int i = 0; i < names.length; i++) {
String[] vals = metadata.getValues(names[i]);

View File

@ -52,7 +52,7 @@ public class ExtractingRequestHandler extends ContentStreamHandlerBase implement
}
@Override
public void init(NamedList args) {
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
super.init(args);
}

View File

@ -231,8 +231,10 @@ class XLSXWriter extends TabularResponseWriter {
}
//NOTE: a document cannot currently contain another document
@SuppressWarnings({"rawtypes"})
List tmpList;
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void writeSolrDocument(String name, SolrDocument doc, ReturnFields returnFields, int idx ) throws IOException {
if (tmpList == null) {
tmpList = new ArrayList(1);
@ -277,7 +279,7 @@ class XLSXWriter extends TabularResponseWriter {
}
@Override
public void writeArray(String name, Iterator val) throws IOException {
public void writeArray(String name, @SuppressWarnings({"rawtypes"})Iterator val) throws IOException {
StringBuffer output = new StringBuffer();
while (val.hasNext()) {
Object v = val.next();

View File

@ -38,7 +38,7 @@ public class JaegerTracerConfigurator extends TracerConfigurator {
}
@Override
public void init(NamedList args) {
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
Object host = args.get(AGENT_HOST);
if (!(host instanceof String)) {
throw new IllegalArgumentException("Expected a required string for param '" + AGENT_HOST + "'");

View File

@ -59,9 +59,10 @@ import org.apache.solr.util.plugin.NamedListInitializedPlugin;
*/
final public class LTRThreadModule extends CloseHook implements NamedListInitializedPlugin {
public static LTRThreadModule getInstance(NamedList args) {
public static LTRThreadModule getInstance(@SuppressWarnings({"rawtypes"})NamedList args) {
final LTRThreadModule threadManager;
@SuppressWarnings({"rawtypes"})
final NamedList threadManagerArgs = extractThreadModuleParams(args);
// if and only if there are thread module args then we want a thread module!
if (threadManagerArgs.size() > 0) {
@ -77,6 +78,7 @@ final public class LTRThreadModule extends CloseHook implements NamedListInitial
private static String CONFIG_PREFIX = "threadModule.";
@SuppressWarnings({"unchecked", "rawtypes"})
private static NamedList extractThreadModuleParams(NamedList args) {
// gather the thread module args from amongst the general args
@ -118,7 +120,8 @@ final public class LTRThreadModule extends CloseHook implements NamedListInitial
}
@Override
public void init(NamedList args) {
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
if (args != null) {
SolrPluginUtils.invokeSetters(this, args);
}

View File

@ -69,6 +69,7 @@ public abstract class Feature extends Query implements Accountable {
final private Map<String,Object> params;
@SuppressWarnings({"rawtypes"})
public static Feature getInstance(SolrResourceLoader solrResourceLoader,
String className, String name, Map<String,Object> params) {
final Feature f = solrResourceLoader.newInstance(

View File

@ -89,6 +89,7 @@ public abstract class LTRScoringModel implements Accountable {
protected final List<Normalizer> norms;
private Integer hashCode; // cached since it shouldn't actually change after construction
@SuppressWarnings({"rawtypes"})
public static LTRScoringModel getInstance(SolrResourceLoader solrResourceLoader,
String className, String name, List<Feature> features,
List<Normalizer> norms,

View File

@ -79,6 +79,7 @@ public class LinearModel extends LTRScoringModel {
protected Float[] featureToWeight;
public void setWeights(Object weights) {
@SuppressWarnings({"unchecked"})
final Map<String,Double> modelWeights = (Map<String,Double>) weights;
for (int ii = 0; ii < features.size(); ++ii) {
final String key = features.get(ii).getName();

View File

@ -155,10 +155,12 @@ public class MultipleAdditiveTreesModel extends LTRScoringModel {
this.threshold = Float.parseFloat(threshold) + NODE_SPLIT_SLACK;
}
@SuppressWarnings({"unchecked"})
public void setLeft(Object left) {
this.left = createRegressionTreeNode((Map<String,Object>) left);
}
@SuppressWarnings({"unchecked"})
public void setRight(Object right) {
this.right = createRegressionTreeNode((Map<String,Object>) right);
}
@ -264,6 +266,7 @@ public class MultipleAdditiveTreesModel extends LTRScoringModel {
this.weight = Float.valueOf(weight);
}
@SuppressWarnings({"unchecked"})
public void setRoot(Object root) {
this.root = createRegressionTreeNode((Map<String,Object>)root);
}
@ -300,6 +303,7 @@ public class MultipleAdditiveTreesModel extends LTRScoringModel {
}
}
@SuppressWarnings({"unchecked"})
public void setTrees(Object trees) {
this.trees = new ArrayList<RegressionTree>();
for (final Object o : (List<Object>) trees) {

View File

@ -127,6 +127,7 @@ public class NeuralNetworkModel extends LTRScoringModel {
}
public void setMatrix(Object matrixObj) {
@SuppressWarnings({"unchecked"})
final List<List<Double>> matrix = (List<List<Double>>) matrixObj;
this.matrixRows = matrix.size();
this.matrixCols = matrix.get(0).size();
@ -140,6 +141,7 @@ public class NeuralNetworkModel extends LTRScoringModel {
}
public void setBias(Object biasObj) {
@SuppressWarnings({"unchecked"})
final List<Double> vector = (List<Double>) biasObj;
this.numUnits = vector.size();
this.biasVector = new float[numUnits];
@ -246,6 +248,7 @@ public class NeuralNetworkModel extends LTRScoringModel {
}
}
@SuppressWarnings({"unchecked"})
protected Layer createLayer(Object o) {
final DefaultLayer layer = new DefaultLayer();
if (o != null) {
@ -254,6 +257,7 @@ public class NeuralNetworkModel extends LTRScoringModel {
return layer;
}
@SuppressWarnings({"unchecked"})
public void setLayers(Object layers) {
this.layers = new ArrayList<Layer>();
for (final Object o : (List<Object>) layers) {

View File

@ -111,6 +111,7 @@ public class LTRFeatureLoggerTransformerFactory extends TransformerFactory {
}
@Override
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings("rawtypes") NamedList args) {
super.init(args);
threadManager = LTRThreadModule.getInstance(args);

View File

@ -79,6 +79,7 @@ public class LTRQParserPlugin extends QParserPlugin implements ResourceLoaderAwa
public static final String RERANK_DOCS = "reRankDocs";
@Override
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings("rawtypes") NamedList args) {
super.init(args);
threadManager = LTRThreadModule.getInstance(args);

View File

@ -123,6 +123,7 @@ public class ManagedModelStore extends ManagedResource implements ManagedResourc
log.info("------ managed models ~ loading ------");
if ((managedData != null) && (managedData instanceof List)) {
@SuppressWarnings({"unchecked"})
final List<Map<String,Object>> up = (List<Map<String,Object>>) managedData;
for (final Map<String,Object> u : up) {
addModelFromMap(u);

View File

@ -77,7 +77,8 @@ public class SchedulerMetricsCollector implements Closeable {
scheduler.scheduleWithFixedDelay(this::collectMetrics, 0, duration, timeUnit);
}
private void collectMetrics() {
private@SuppressWarnings({"try"})
void collectMetrics() {
try (Histogram.Timer timer = metricsCollectionTime.startTimer()) {
log.info("Beginning metrics collection");

View File

@ -88,6 +88,7 @@ public class MetricsQuery {
return jsonQueries;
}
@SuppressWarnings({"unchecked", "rawtypes"})
public static List<MetricsQuery> from(Node node) throws JsonQueryException {
List<MetricsQuery> metricsQueries = new ArrayList<>();

View File

@ -57,13 +57,15 @@ public class PrometheusExporterSettings {
}
public static PrometheusExporterSettings from(Node settings) {
@SuppressWarnings({"rawtypes"})
NamedList config = DOMUtil.childNodesToNamedList(settings);
Builder builder = builder();
@SuppressWarnings({"unchecked", "rawtypes"})
List<NamedList> httpClientSettings = config.getAll("httpClients");
for (NamedList entry : httpClientSettings) {
for (@SuppressWarnings({"rawtypes"})NamedList entry : httpClientSettings) {
Integer connectionTimeout = (Integer) entry.get("connectionTimeout");
if (connectionTimeout != null) {
builder.withConnectionHttpTimeout(connectionTimeout);

View File

@ -29,6 +29,7 @@ public class Async {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@SuppressWarnings({"rawtypes"})
public static <T> CompletableFuture<List<T>> waitForAllSuccessfulResponses(List<CompletableFuture<T>> futures) {
CompletableFuture<Void> completed = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));

View File

@ -95,7 +95,7 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
private Map<String,String> customTools = new HashMap<String,String>();
@Override
public void init(NamedList args) {
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
log.warn("VelocityResponseWriter is deprecated. This may be removed in future Solr releases. Please SOLR-14065.");
fileResourceLoaderBaseDir = null;
String templateBaseDir = (String) args.get(TEMPLATE_BASE_DIR);
@ -115,9 +115,11 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
initPropertiesFileName = (String) args.get(PROPERTIES_FILE);
@SuppressWarnings({"rawtypes"})
NamedList tools = (NamedList)args.get("tools");
if (tools != null) {
for(Object t : tools) {
@SuppressWarnings({"rawtypes"})
Map.Entry tool = (Map.Entry)t;
customTools.put(tool.getKey().toString(), tool.getValue().toString());
}
@ -228,11 +230,13 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
}
}
@SuppressWarnings({"unchecked"})
private VelocityContext createContext(SolrQueryRequest request, SolrQueryResponse response) {
VelocityContext context = new VelocityContext();
// Register useful Velocity "tools"
String locale = request.getParams().get(LOCALE);
@SuppressWarnings({"rawtypes"})
Map toolConfig = new HashMap();
toolConfig.put("locale", locale);