From ed739562761c1a9260d70424e4b40bda040c8da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 12 Jul 2018 12:57:15 +0200 Subject: [PATCH] Remove some dead code Removing some dead code or supressing warnings where apropriate. Most of the time the variable tested for null is dereferenced earlier or never used before. --- .../support/MultiValuesSourceParser.java | 4 -- .../support/nodes/TransportNodesAction.java | 57 +++++++++---------- .../common/geo/parsers/GeoJsonParser.java | 6 +- .../blobstore/BlobStoreRepository.java | 7 +-- .../autodetect/writer/FieldConfigWriter.java | 3 +- 5 files changed, 31 insertions(+), 46 deletions(-) diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceParser.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceParser.java index 22a90b552d920..93ef469245ca8 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceParser.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceParser.java @@ -78,7 +78,6 @@ private MultiValuesSourceParser(boolean formattable, ValuesSourceType valuesSour throws IOException { List fields = null; - ValueType valueType = null; String format = null; Map missingMap = null; Map otherOptions = new HashMap<>(); @@ -145,9 +144,6 @@ private MultiValuesSourceParser(boolean formattable, ValuesSourceType valuesSour if (fields != null) { factory.fields(fields); } - if (valueType != null) { - factory.valueType(valueType); - } if (format != null) { factory.format(format); } diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index b232d849223b9..2be4e5bf053cc 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -22,7 +22,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; -import org.elasticsearch.action.NoSuchNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.cluster.ClusterState; @@ -179,37 +178,33 @@ void start() { final DiscoveryNode node = nodes[i]; final String nodeId = node.getId(); try { - if (node == null) { - onFailure(idx, nodeId, new NoSuchNodeException(nodeId)); - } else { - TransportRequest nodeRequest = newNodeRequest(nodeId, request); - if (task != null) { - nodeRequest.setParentTask(clusterService.localNode().getId(), task.getId()); - } - - transportService.sendRequest(node, transportNodeAction, nodeRequest, builder.build(), - new TransportResponseHandler() { - @Override - public NodeResponse newInstance() { - return newNodeResponse(); - } - - @Override - public void handleResponse(NodeResponse response) { - onOperation(idx, response); - } - - @Override - public void handleException(TransportException exp) { - onFailure(idx, node.getId(), exp); - } - - @Override - public String executor() { - return ThreadPool.Names.SAME; - } - }); + TransportRequest nodeRequest = newNodeRequest(nodeId, request); + if (task != null) { + nodeRequest.setParentTask(clusterService.localNode().getId(), task.getId()); } + + transportService.sendRequest(node, transportNodeAction, nodeRequest, builder.build(), + new TransportResponseHandler() { + @Override + public NodeResponse newInstance() { + return newNodeResponse(); + } + + @Override + public void handleResponse(NodeResponse response) { + onOperation(idx, response); + } + + @Override + public void handleException(TransportException exp) { + onFailure(idx, node.getId(), exp); + } + + @Override + public String executor() { + return ThreadPool.Names.SAME; + } + }); } catch (Exception e) { onFailure(idx, nodeId, e); } diff --git a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java index af0e0248471d5..45ce2b610ca0c 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java +++ b/server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.common.geo.parsers; -import org.locationtech.jts.geom.Coordinate; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.geo.GeoPoint; @@ -29,6 +28,7 @@ import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.GeoShapeFieldMapper; +import org.locationtech.jts.geom.Coordinate; import java.io.IOException; import java.util.ArrayList; @@ -130,10 +130,6 @@ protected static ShapeBuilder parse(XContentParser parser, GeoShapeFieldMapper s CircleBuilder.TYPE); } - if (shapeType == null) { - throw new ElasticsearchParseException("shape type [{}] not included", shapeType); - } - if (shapeType.equals(GeoShapeType.GEOMETRYCOLLECTION)) { return geometryCollections; } diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index 86131fe468d28..c6e45c44fba8b 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -1478,11 +1478,8 @@ public void restore() throws IOException { filesToRecover.add(fileInfo); recoveryState.getIndex().addFileDetail(fileInfo.name(), fileInfo.length(), false); if (logger.isTraceEnabled()) { - if (md == null) { - logger.trace("[{}] [{}] recovering [{}] from [{}], does not exists in local store", shardId, snapshotId, fileInfo.physicalName(), fileInfo.name()); - } else { - logger.trace("[{}] [{}] recovering [{}] from [{}], exists in local store but is different", shardId, snapshotId, fileInfo.physicalName(), fileInfo.name()); - } + logger.trace("[{}] [{}] recovering [{}] from [{}], exists in local store but is different", shardId, snapshotId, + fileInfo.physicalName(), fileInfo.name()); } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java index a8c33dd98b638..95d45183e777d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java @@ -10,7 +10,6 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.core.ml.calendars.ScheduledEvent; import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig; import org.elasticsearch.xpack.core.ml.job.config.DefaultDetectorDescription; @@ -18,6 +17,7 @@ import org.elasticsearch.xpack.core.ml.job.config.Detector; import org.elasticsearch.xpack.core.ml.job.config.MlFilter; import org.elasticsearch.xpack.core.ml.utils.MlStrings; +import org.elasticsearch.xpack.ml.MachineLearning; import java.io.IOException; import java.io.OutputStreamWriter; @@ -59,6 +59,7 @@ public FieldConfigWriter(AnalysisConfig config, Set filters, List