Skip to content

Commit

Permalink
Correct implemented interface of ParsedReverseNested (#35455)
Browse files Browse the repository at this point in the history
The ParsedReverseNested implementation should implement the ReverseNested
interface and not the Nested interface. Although this is an empty marker
interface it is confusing and can lead to casting errors. Also adding a test to
check that both ParsedNested and ParsedReverseNested implement the correct
interface.

Closes #35449
  • Loading branch information
Christoph Büscher committed Nov 13, 2018
1 parent 65f8ec5 commit 9b5d6f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.io.IOException;

public class ParsedReverseNested extends ParsedSingleBucketAggregation implements Nested {
public class ParsedReverseNested extends ParsedSingleBucketAggregation implements ReverseNested {

@Override
public String getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
import org.elasticsearch.search.aggregations.ParsedAggregation;
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;

import java.io.IOException;
import java.util.List;
import java.util.Map;

Expand All @@ -49,4 +51,10 @@ protected Reader<InternalNested> instanceReader() {
protected Class<? extends ParsedSingleBucketAggregation> implementationClass() {
return ParsedNested.class;
}

@Override
protected void assertFromXContent(InternalNested aggregation, ParsedAggregation parsedAggregation) throws IOException {
super.assertFromXContent(aggregation, parsedAggregation);
assertTrue(parsedAggregation instanceof Nested);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
import org.elasticsearch.search.aggregations.ParsedAggregation;
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;

import java.io.IOException;
import java.util.List;
import java.util.Map;

Expand All @@ -49,4 +51,10 @@ protected Reader<InternalReverseNested> instanceReader() {
protected Class<? extends ParsedSingleBucketAggregation> implementationClass() {
return ParsedReverseNested.class;
}

@Override
protected void assertFromXContent(InternalReverseNested aggregation, ParsedAggregation parsedAggregation) throws IOException {
super.assertFromXContent(aggregation, parsedAggregation);
assertTrue(parsedAggregation instanceof ReverseNested);
}
}

0 comments on commit 9b5d6f9

Please sign in to comment.