Skip to content

Commit c686fe0

Browse files
committed
Less nesting
1 parent 055ed19 commit c686fe0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketMetricsPipelineAggregationBuilder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ protected void validate(ValidationContext context) {
117117
Optional<AggregationBuilder> aggBuilder = context.getSiblingAggregations().stream()
118118
.filter(builder -> builder.getName().equals(firstAgg))
119119
.findAny();
120-
if (aggBuilder.isPresent()) {
121-
if ((aggBuilder.get() instanceof MultiBucketAggregationBuilder) == false) {
122-
context.addValidationError("The first aggregation in " + PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
123-
+ " must be a multi-bucket aggregation for aggregation [" + name + "] found :"
124-
+ aggBuilder.get().getClass().getName() + " for buckets path: " + bucketsPaths[0]);
125-
}
126-
} else {
120+
if (aggBuilder.isEmpty()) {
127121
context.addBucketPathValidationError("aggregation does not exist for aggregation [" + name + "]: " + bucketsPaths[0]);
122+
return;
123+
}
124+
if ((aggBuilder.get() instanceof MultiBucketAggregationBuilder) == false) {
125+
context.addValidationError("The first aggregation in " + PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
126+
+ " must be a multi-bucket aggregation for aggregation [" + name + "] found :"
127+
+ aggBuilder.get().getClass().getName() + " for buckets path: " + bucketsPaths[0]);
128128
}
129129
}
130130

0 commit comments

Comments
 (0)