Skip to content

Commit 35ae871

Browse files
author
Christoph Büscher
authored
Remove some dead code (#31993)
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.
1 parent eb675a1 commit 35ae871

File tree

5 files changed

+39
-51
lines changed

5 files changed

+39
-51
lines changed

modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/ArrayValuesSourceParser.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ private ArrayValuesSourceParser(boolean formattable, ValuesSourceType valuesSour
7878
throws IOException {
7979

8080
List<String> fields = null;
81-
ValueType valueType = null;
8281
String format = null;
8382
Map<String, Object> missingMap = null;
8483
Map<ParseField, Object> otherOptions = new HashMap<>();
@@ -145,9 +144,6 @@ private ArrayValuesSourceParser(boolean formattable, ValuesSourceType valuesSour
145144
if (fields != null) {
146145
factory.fields(fields);
147146
}
148-
if (valueType != null) {
149-
factory.valueType(valueType);
150-
}
151147
if (format != null) {
152148
factory.format(format);
153149
}

server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.logging.log4j.message.ParameterizedMessage;
2323
import org.elasticsearch.action.ActionListener;
2424
import org.elasticsearch.action.FailedNodeException;
25-
import org.elasticsearch.action.NoSuchNodeException;
2625
import org.elasticsearch.action.support.ActionFilters;
2726
import org.elasticsearch.action.support.HandledTransportAction;
2827
import org.elasticsearch.cluster.ClusterState;
@@ -179,37 +178,33 @@ void start() {
179178
final DiscoveryNode node = nodes[i];
180179
final String nodeId = node.getId();
181180
try {
182-
if (node == null) {
183-
onFailure(idx, nodeId, new NoSuchNodeException(nodeId));
184-
} else {
185-
TransportRequest nodeRequest = newNodeRequest(nodeId, request);
186-
if (task != null) {
187-
nodeRequest.setParentTask(clusterService.localNode().getId(), task.getId());
188-
}
189-
190-
transportService.sendRequest(node, transportNodeAction, nodeRequest, builder.build(),
191-
new TransportResponseHandler<NodeResponse>() {
192-
@Override
193-
public NodeResponse newInstance() {
194-
return newNodeResponse();
195-
}
196-
197-
@Override
198-
public void handleResponse(NodeResponse response) {
199-
onOperation(idx, response);
200-
}
201-
202-
@Override
203-
public void handleException(TransportException exp) {
204-
onFailure(idx, node.getId(), exp);
205-
}
206-
207-
@Override
208-
public String executor() {
209-
return ThreadPool.Names.SAME;
210-
}
211-
});
181+
TransportRequest nodeRequest = newNodeRequest(nodeId, request);
182+
if (task != null) {
183+
nodeRequest.setParentTask(clusterService.localNode().getId(), task.getId());
212184
}
185+
186+
transportService.sendRequest(node, transportNodeAction, nodeRequest, builder.build(),
187+
new TransportResponseHandler<NodeResponse>() {
188+
@Override
189+
public NodeResponse newInstance() {
190+
return newNodeResponse();
191+
}
192+
193+
@Override
194+
public void handleResponse(NodeResponse response) {
195+
onOperation(idx, response);
196+
}
197+
198+
@Override
199+
public void handleException(TransportException exp) {
200+
onFailure(idx, node.getId(), exp);
201+
}
202+
203+
@Override
204+
public String executor() {
205+
return ThreadPool.Names.SAME;
206+
}
207+
});
213208
} catch (Exception e) {
214209
onFailure(idx, nodeId, e);
215210
}

server/src/main/java/org/elasticsearch/common/geo/parsers/GeoJsonParser.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.elasticsearch.common.geo.parsers;
2020

21-
import org.locationtech.jts.geom.Coordinate;
2221
import org.elasticsearch.ElasticsearchParseException;
2322
import org.elasticsearch.common.Explicit;
2423
import org.elasticsearch.common.geo.GeoPoint;
@@ -29,6 +28,7 @@
2928
import org.elasticsearch.common.unit.DistanceUnit;
3029
import org.elasticsearch.common.xcontent.XContentParser;
3130
import org.elasticsearch.index.mapper.GeoShapeFieldMapper;
31+
import org.locationtech.jts.geom.Coordinate;
3232

3333
import java.io.IOException;
3434
import java.util.ArrayList;
@@ -130,10 +130,6 @@ protected static ShapeBuilder parse(XContentParser parser, GeoShapeFieldMapper s
130130
CircleBuilder.TYPE);
131131
}
132132

133-
if (shapeType == null) {
134-
throw new ElasticsearchParseException("shape type [{}] not included", shapeType);
135-
}
136-
137133
if (shapeType.equals(GeoShapeType.GEOMETRYCOLLECTION)) {
138134
return geometryCollections;
139135
}

server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,11 +1554,8 @@ public void restore() throws IOException {
15541554
filesToRecover.add(fileInfo);
15551555
recoveryState.getIndex().addFileDetail(fileInfo.name(), fileInfo.length(), false);
15561556
if (logger.isTraceEnabled()) {
1557-
if (md == null) {
1558-
logger.trace("[{}] [{}] recovering [{}] from [{}], does not exists in local store", shardId, snapshotId, fileInfo.physicalName(), fileInfo.name());
1559-
} else {
1560-
logger.trace("[{}] [{}] recovering [{}] from [{}], exists in local store but is different", shardId, snapshotId, fileInfo.physicalName(), fileInfo.name());
1561-
}
1557+
logger.trace("[{}] [{}] recovering [{}] from [{}], exists in local store but is different", shardId, snapshotId,
1558+
fileInfo.physicalName(), fileInfo.name());
15621559
}
15631560
}
15641561

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import org.elasticsearch.common.xcontent.ToXContent;
1111
import org.elasticsearch.common.xcontent.XContentBuilder;
1212
import org.elasticsearch.common.xcontent.XContentFactory;
13-
import org.elasticsearch.xpack.ml.MachineLearning;
1413
import org.elasticsearch.xpack.core.ml.calendars.ScheduledEvent;
1514
import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig;
1615
import org.elasticsearch.xpack.core.ml.job.config.DefaultDetectorDescription;
1716
import org.elasticsearch.xpack.core.ml.job.config.DetectionRule;
1817
import org.elasticsearch.xpack.core.ml.job.config.Detector;
1918
import org.elasticsearch.xpack.core.ml.job.config.MlFilter;
2019
import org.elasticsearch.xpack.core.ml.utils.MlStrings;
20+
import org.elasticsearch.xpack.ml.MachineLearning;
2121

2222
import java.io.IOException;
2323
import java.io.OutputStreamWriter;
@@ -66,11 +66,7 @@ public void write() throws IOException {
6666
writeFilters(contents);
6767
writeDetectors(contents);
6868
writeScheduledEvents(contents);
69-
70-
if (MachineLearning.CATEGORIZATION_TOKENIZATION_IN_JAVA == false) {
71-
writeAsEnumeratedSettings(CATEGORIZATION_FILTER_PREFIX, config.getCategorizationFilters(),
72-
contents, true);
73-
}
69+
writeCategorizationFilters(contents);
7470

7571
// As values are written as entire settings rather than part of a
7672
// clause no quoting is needed
@@ -80,6 +76,14 @@ public void write() throws IOException {
8076
writer.write(contents.toString());
8177
}
8278

79+
@SuppressWarnings("unused") // CATEGORIZATION_TOKENIZATION_IN_JAVA is used for performance testing
80+
private void writeCategorizationFilters(StringBuilder contents) {
81+
if (MachineLearning.CATEGORIZATION_TOKENIZATION_IN_JAVA == false) {
82+
writeAsEnumeratedSettings(CATEGORIZATION_FILTER_PREFIX, config.getCategorizationFilters(),
83+
contents, true);
84+
}
85+
}
86+
8387
private void writeDetectors(StringBuilder contents) throws IOException {
8488
int counter = 0;
8589
for (Detector detector : config.getDetectors()) {

0 commit comments

Comments
 (0)