Skip to content

Commit

Permalink
Revert "Checkstyle shadowed vars pt11 (#81556)"
Browse files Browse the repository at this point in the history
This reverts commit 882728e.
  • Loading branch information
pugnascotia committed Dec 22, 2021
1 parent 882728e commit 986d18f
Show file tree
Hide file tree
Showing 69 changed files with 337 additions and 346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public int hashCode() {
return Objects.hash(classHash(), fieldName, queryType, lengthType, from, to);
}

@SuppressWarnings("HiddenField")
public enum QueryType {
INTERSECTS {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ CompositeListener addListener(ActionListener<R> listener) {
}

@Override
@SuppressWarnings("HiddenField")
public void onResponse(R response) {
synchronized (this) {
this.response = response;
Expand All @@ -97,7 +96,6 @@ public void onResponse(R response) {
}

@Override
@SuppressWarnings("HiddenField")
public void onFailure(Exception failure) {
synchronized (this) {
this.failure = failure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ public boolean verify() {
*/
public PutRepositoryRequest source(Map<String, Object> repositoryDefinition) {
for (Map.Entry<String, Object> entry : repositoryDefinition.entrySet()) {
String key = entry.getKey();
if (key.equals("type")) {
String name = entry.getKey();
if (name.equals("type")) {
type(entry.getValue().toString());
} else if (key.equals("settings")) {
} else if (name.equals("settings")) {
if ((entry.getValue() instanceof Map) == false) {
throw new IllegalArgumentException("Malformed settings section, should include an inner object");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
ConstructingObjectParser<SnapshotIndexStatus, String> innerParser = new ConstructingObjectParser<>(
"snapshot_index_status",
true,
(Object[] parsedObjects, String indexName) -> {
(Object[] parsedObjects, String index) -> {
int i = 0;
SnapshotShardsStats shardsStats = ((SnapshotShardsStats) parsedObjects[i++]);
SnapshotStats stats = ((SnapshotStats) parsedObjects[i++]);
Expand All @@ -138,7 +138,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
indexShards.put(shardStatus.getShardId().getId(), shardStatus);
}
}
return new SnapshotIndexStatus(indexName, indexShards, shardsStats, stats);
return new SnapshotIndexStatus(index, indexShards, shardsStats, stats);
}
);
innerParser.declareObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,23 @@ public Map<String, SnapshotIndexStatus> getIndices() {
return this.indicesStatus;
}

Map<String, SnapshotIndexStatus> indexStatusMap = new HashMap<>();
Map<String, SnapshotIndexStatus> indicesStatus = new HashMap<>();

Set<String> indices = new HashSet<>();
for (SnapshotIndexShardStatus shard : shards) {
indices.add(shard.getIndex());
}

for (String index : indices) {
List<SnapshotIndexShardStatus> shardStatuses = new ArrayList<>();
List<SnapshotIndexShardStatus> shards = new ArrayList<>();
for (SnapshotIndexShardStatus shard : this.shards) {
if (shard.getIndex().equals(index)) {
shardStatuses.add(shard);
shards.add(shard);
}
}
indexStatusMap.put(index, new SnapshotIndexStatus(index, shardStatuses));
indicesStatus.put(index, new SnapshotIndexStatus(index, shards));
}
this.indicesStatus = unmodifiableMap(indexStatusMap);
this.indicesStatus = unmodifiableMap(indicesStatus);
return this.indicesStatus;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,21 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public String toString() {
String json = "_na_";
String source = "_na_";

try {
json = XContentHelper.convertToJson(content, false, xContentType);
source = XContentHelper.convertToJson(content, false, xContentType);
} catch (Exception e) {
// ignore
}

return "put stored script {id [" + id + "]" + (context != null ? ", context [" + context + "]" : "") + ", content [" + json + "]}";
return "put stored script {id ["
+ id
+ "]"
+ (context != null ? ", context [" + context + "]" : "")
+ ", content ["
+ source
+ "]}";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ public CreateIndexRequest source(Map<String, ?> source, DeprecationHandler depre
}
settings((Map<String, Object>) entry.getValue());
} else if (MAPPINGS.match(name, deprecationHandler)) {
Map<String, Object> typeToMappings = (Map<String, Object>) entry.getValue();
for (Map.Entry<String, Object> entry1 : typeToMappings.entrySet()) {
Map<String, Object> mappings = (Map<String, Object>) entry.getValue();
for (Map.Entry<String, Object> entry1 : mappings.entrySet()) {
mapping(entry1.getKey(), (Map<String, Object>) entry1.getValue());
}
} else if (ALIASES.match(name, deprecationHandler)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Map<String, IndexSegments> getIndices() {
if (indicesSegments != null) {
return indicesSegments;
}
Map<String, IndexSegments> indicesSegmentsByIndex = new HashMap<>();
Map<String, IndexSegments> indicesSegments = new HashMap<>();

Set<String> indices = new HashSet<>();
for (ShardSegments shard : shards) {
Expand All @@ -75,8 +75,8 @@ public Map<String, IndexSegments> getIndices() {
}
indicesSegments.put(indexName, new IndexSegments(indexName, shards.toArray(new ShardSegments[shards.size()])));
}
this.indicesSegments = indicesSegmentsByIndex;
return indicesSegmentsByIndex;
this.indicesSegments = indicesSegments;
return indicesSegments;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}

public UpdateSettingsRequest fromXContent(XContentParser parser) throws IOException {
Map<String, Object> settingsMaps = new HashMap<>();
Map<String, Object> bodySettingsMap = parser.map();
Object innerBodySettings = bodySettingsMap.get("settings");
Map<String, Object> settings = new HashMap<>();
Map<String, Object> bodySettings = parser.map();
Object innerBodySettings = bodySettings.get("settings");
// clean up in case the body is wrapped with "settings" : { ... }
if (innerBodySettings instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> innerBodySettingsMap = (Map<String, Object>) innerBodySettings;
settingsMaps.putAll(innerBodySettingsMap);
checkMixedRequest(bodySettingsMap);
settings.putAll(innerBodySettingsMap);
checkMixedRequest(bodySettings);
} else {
settingsMaps.putAll(bodySettingsMap);
settings.putAll(bodySettings);
}
return this.settings(settingsMaps);
return this.settings(settings);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ void start() {
}
}

@SuppressWarnings("HiddenField")
private void listStartedShards(
ShardId shardId,
String customDataPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public class IndicesStatsResponse extends BroadcastResponse {

public Map<ShardRouting, ShardStats> asMap() {
if (this.shardStatsMap == null) {
Map<ShardRouting, ShardStats> mutableShardStatsMap = new HashMap<>();
Map<ShardRouting, ShardStats> shardStatsMap = new HashMap<>();
for (ShardStats ss : shards) {
mutableShardStatsMap.put(ss.getShardRouting(), ss);
shardStatsMap.put(ss.getShardRouting(), ss);
}
this.shardStatsMap = unmodifiableMap(mutableShardStatsMap);
this.shardStatsMap = unmodifiableMap(shardStatsMap);
}
return this.shardStatsMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ public PutIndexTemplateRequest source(XContentBuilder templateBuilder) {
*/
@SuppressWarnings("unchecked")
public PutIndexTemplateRequest source(Map<String, Object> templateSource) {
for (Map.Entry<String, Object> entry : templateSource.entrySet()) {
String key = entry.getKey();
if (key.equals("index_patterns")) {
Map<String, Object> source = templateSource;
for (Map.Entry<String, Object> entry : source.entrySet()) {
String name = entry.getKey();
if (name.equals("index_patterns")) {
if (entry.getValue() instanceof String) {
patterns(Collections.singletonList((String) entry.getValue()));
} else if (entry.getValue() instanceof List) {
Expand All @@ -308,21 +309,21 @@ public PutIndexTemplateRequest source(Map<String, Object> templateSource) {
} else {
throw new IllegalArgumentException("Malformed [index_patterns] value, should be a string or a list of strings");
}
} else if (key.equals("order")) {
} else if (name.equals("order")) {
order(XContentMapValues.nodeIntegerValue(entry.getValue(), order()));
} else if ("version".equals(key)) {
} else if ("version".equals(name)) {
if ((entry.getValue() instanceof Integer) == false) {
throw new IllegalArgumentException("Malformed [version] value, should be an integer");
}
version((Integer) entry.getValue());
} else if (key.equals("settings")) {
} else if (name.equals("settings")) {
if ((entry.getValue() instanceof Map) == false) {
throw new IllegalArgumentException("Malformed [settings] section, should include an inner object");
}
settings((Map<String, Object>) entry.getValue());
} else if (key.equals("mappings")) {
Map<String, Object> mappings1 = (Map<String, Object>) entry.getValue();
for (Map.Entry<String, Object> entry1 : mappings1.entrySet()) {
} else if (name.equals("mappings")) {
Map<String, Object> mappings = (Map<String, Object>) entry.getValue();
for (Map.Entry<String, Object> entry1 : mappings.entrySet()) {
if ((entry1.getValue() instanceof Map) == false) {
throw new IllegalArgumentException(
"Malformed [mappings] section for type ["
Expand All @@ -332,10 +333,10 @@ public PutIndexTemplateRequest source(Map<String, Object> templateSource) {
}
mapping((Map<String, Object>) entry1.getValue());
}
} else if (key.equals("aliases")) {
} else if (name.equals("aliases")) {
aliases((Map<String, Object>) entry.getValue());
} else {
throw new ElasticsearchParseException("unknown key [{}] in the template ", key);
throw new ElasticsearchParseException("unknown key [{}] in the template ", name);
}
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ private Tuple<BulkRequest, Long> newBulkRequestIfNeeded() {
if (isOverTheLimit() == false) {
return null;
}
final BulkRequest currentBulkRequest = this.bulkRequest;
final BulkRequest bulkRequest = this.bulkRequest;
this.bulkRequest = bulkRequestSupplier.get();
return new Tuple<>(currentBulkRequest, executionIdGen.incrementAndGet());
return new Tuple<>(bulkRequest, executionIdGen.incrementAndGet());
}

// may be executed without a lock
Expand All @@ -529,11 +529,11 @@ private void execute(BulkRequest bulkRequest, long executionId) {
// needs to be executed under a lock
private void execute() {
if (flushSupplier.get()) {
final BulkRequest currentBulkRequest = this.bulkRequest;
final BulkRequest bulkRequest = this.bulkRequest;
final long executionId = executionIdGen.incrementAndGet();

this.bulkRequest = bulkRequestSupplier.get();
execute(currentBulkRequest, executionId);
execute(bulkRequest, executionId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ boolean isOnlySystem(BulkRequest request, SortedMap<String, IndexAbstraction> in
return request.getIndices().stream().allMatch(indexName -> isSystemIndex(indicesLookup, systemIndices, indexName));
}

private boolean isSystemIndex(SortedMap<String, IndexAbstraction> indicesLookup, SystemIndices systemIndicesToCheck, String indexName) {
private boolean isSystemIndex(SortedMap<String, IndexAbstraction> indicesLookup, SystemIndices systemIndices, String indexName) {
final IndexAbstraction abstraction = indicesLookup.get(indexName);
if (abstraction != null) {
return abstraction.isSystem();
} else {
return systemIndicesToCheck.isSystemIndex(indexName);
return systemIndices.isSystemIndex(indexName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

private void buildExplanation(XContentBuilder builder, Explanation currentExplanation) throws IOException {
builder.field(VALUE.getPreferredName(), currentExplanation.getValue());
builder.field(DESCRIPTION.getPreferredName(), currentExplanation.getDescription());
Explanation[] innerExps = currentExplanation.getDetails();
private void buildExplanation(XContentBuilder builder, Explanation explanation) throws IOException {
builder.field(VALUE.getPreferredName(), explanation.getValue());
builder.field(DESCRIPTION.getPreferredName(), explanation.getDescription());
Explanation[] innerExps = explanation.getDetails();
if (innerExps != null) {
builder.startArray(DETAILS.getPreferredName());
for (Explanation innerExplanation : innerExps) {
for (Explanation exp : innerExps) {
builder.startObject();
buildExplanation(builder, innerExplanation);
buildExplanation(builder, exp);
builder.endObject();
}
builder.endArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ static class Builder {
/**
* Collect the field capabilities for an index.
*/
@SuppressWarnings("HiddenField")
void add(
String index,
boolean isMetadataField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,22 +360,22 @@ public IndexRequest source(Map<String, ?> source) throws ElasticsearchGeneration
/**
* Index the Map as the provided content type.
*
* @param sourceMap The map to index
* @param source The map to index
*/
public IndexRequest source(Map<String, ?> sourceMap, XContentType xContentType) throws ElasticsearchGenerationException {
public IndexRequest source(Map<String, ?> source, XContentType contentType) throws ElasticsearchGenerationException {
try {
XContentBuilder builder = XContentFactory.contentBuilder(xContentType);
builder.map(sourceMap);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(source);
return source(builder);
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + sourceMap + "]", e);
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}
}

/**
* Sets the document source to index.
*
* Note, its preferable to either set it using {@link #source(XContentBuilder)}
* Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}
* or using the {@link #source(byte[], XContentType)}.
*/
public IndexRequest source(String source, XContentType xContentType) {
Expand Down Expand Up @@ -409,11 +409,11 @@ public IndexRequest source(Object... source) {
* valid String representation.</b>
* </p>
*/
public IndexRequest source(XContentType xContentType, Object... sources) {
if (sources.length % 2 != 0) {
throw new IllegalArgumentException("The number of object passed must be even but was [" + sources.length + "]");
public IndexRequest source(XContentType xContentType, Object... source) {
if (source.length % 2 != 0) {
throw new IllegalArgumentException("The number of object passed must be even but was [" + source.length + "]");
}
if (sources.length == 2 && sources[0] instanceof BytesReference && sources[1] instanceof Boolean) {
if (source.length == 2 && source[0] instanceof BytesReference && source[1] instanceof Boolean) {
throw new IllegalArgumentException(
"you are using the removed method for source with bytes and unsafe flag, the unsafe flag"
+ " was removed, please just use source(BytesReference)"
Expand All @@ -422,8 +422,8 @@ public IndexRequest source(XContentType xContentType, Object... sources) {
try {
XContentBuilder builder = XContentFactory.contentBuilder(xContentType);
builder.startObject();
for (int i = 0; i < sources.length; i++) {
builder.field(sources[i++].toString(), sources[i]);
for (int i = 0; i < source.length; i++) {
builder.field(source[i++].toString(), source[i]);
}
builder.endObject();
return source(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ public static SimulateProcessorResult fromXContent(XContentParser parser) {
return PARSER.apply(parser, null);
}

Status getStatus(String typeValue) {
Status getStatus(String type) {
// if no condition, or condition passed
if (conditionalWithResult == null || conditionalWithResult.v2()) {
if (conditionalWithResult == null || (conditionalWithResult != null && conditionalWithResult.v2())) {
if (failure != null) {
if (ingestDocument == null) {
return Status.ERROR;
} else {
return Status.ERROR_IGNORED;
}
} else if (ingestDocument == null && "pipeline".equals(typeValue) == false) {
} else if (ingestDocument == null && "pipeline".equals(type) == false) {
return Status.DROPPED;
}
return Status.SUCCESS;
Expand Down

0 comments on commit 986d18f

Please sign in to comment.