Skip to content

Commit 4adfa4d

Browse files
author
elasticsearchmachine
committed
[CI] Auto commit changes from spotless
1 parent 2a697ef commit 4adfa4d

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,29 @@ public class ClusterAllocationExplainRequest extends MasterNodeRequest<ClusterAl
3131
private static final ObjectParser<ClusterAllocationExplainRequest, Void> PARSER = new ObjectParser<>("cluster/allocation/explain");
3232
static {
3333
PARSER.declareString(ClusterAllocationExplainRequest::setIndex, new ParseField("index"));
34-
PARSER.declareField(
35-
ClusterAllocationExplainRequest::setShard,
36-
(xContentParser) -> {
37-
if (xContentParser.currentToken() == XContentParser.Token.VALUE_NUMBER) {
38-
if (xContentParser.numberType() == XContentParser.NumberType.INT) {
39-
return xContentParser.intValue();
34+
PARSER.declareField(ClusterAllocationExplainRequest::setShard, (xContentParser) -> {
35+
if (xContentParser.currentToken() == XContentParser.Token.VALUE_NUMBER) {
36+
if (xContentParser.numberType() == XContentParser.NumberType.INT) {
37+
return xContentParser.intValue();
38+
} else {
39+
throw new IllegalArgumentException("Expected an integer value for [shard]");
40+
}
41+
} else if (xContentParser.currentToken() == XContentParser.Token.VALUE_STRING) {
42+
String text = xContentParser.text();
43+
try {
44+
// Only accept if the string is a valid integer representation
45+
if (text.matches("[-+]?\\d+")) {
46+
return Integer.parseInt(text);
4047
} else {
41-
throw new IllegalArgumentException("Expected an integer value for [shard]");
42-
}
43-
} else if (xContentParser.currentToken() == XContentParser.Token.VALUE_STRING) {
44-
String text = xContentParser.text();
45-
try {
46-
// Only accept if the string is a valid integer representation
47-
if (text.matches("[-+]?\\d+")) {
48-
return Integer.parseInt(text);
49-
} else {
50-
throw new IllegalArgumentException("String value for [shard] must be an integer, but was: " + text);
51-
}
52-
} catch (NumberFormatException e) {
53-
throw new IllegalArgumentException("Invalid integer value for [shard]: " + text, e);
48+
throw new IllegalArgumentException("String value for [shard] must be an integer, but was: " + text);
5449
}
55-
} else {
56-
throw new IllegalArgumentException("Expected an integer for [shard]");
50+
} catch (NumberFormatException e) {
51+
throw new IllegalArgumentException("Invalid integer value for [shard]: " + text, e);
5752
}
58-
},
59-
new ParseField("shard"),
60-
ObjectParser.ValueType.INT
61-
);
53+
} else {
54+
throw new IllegalArgumentException("Expected an integer for [shard]");
55+
}
56+
}, new ParseField("shard"), ObjectParser.ValueType.INT);
6257
PARSER.declareBoolean(ClusterAllocationExplainRequest::setPrimary, new ParseField("primary"));
6358
PARSER.declareString(ClusterAllocationExplainRequest::setCurrentNode, new ParseField("current_node"));
6459
}

0 commit comments

Comments
 (0)