-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compiler warnings in :server - part 2 #75792
Fix compiler warnings in :server - part 2 #75792
Conversation
Pinging @elastic/es-delivery (Team:Delivery) |
@elasticmachine run elasticsearch-ci/bwc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few questions but otherwise LGTM.
@@ -158,7 +158,7 @@ public void collect(int doc, long bucket) throws IOException { | |||
} | |||
|
|||
@Override | |||
LeafBucketCollector getLeafCollector(Comparable value, LeafReaderContext context, LeafBucketCollector next) { | |||
LeafBucketCollector getLeafCollector(Comparable<?> value, LeafReaderContext context, LeafBucketCollector next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cases like this, shouldn't use Comparable<Double>
here so we can enforce this at compile time instead of adding an explicit runtime check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, we need to update this method on SingleDimensionValuesSource
to use the proper generic type argument instead of a wildcard. We probably have missed this in other areas as well. We should go back and check where we've used wildcards that there isn't already a proper type argument we should be using instead.
.../src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java
Show resolved
Hide resolved
@@ -97,7 +97,7 @@ public String getPreferredName() { | |||
private DateHistogramInterval dateHistogramInterval; | |||
private IntervalTypeEnum intervalType = IntervalTypeEnum.NONE; | |||
|
|||
public static <T extends DateIntervalConsumer> void declareIntervalFields(ObjectParser<T, String> parser) { | |||
public static <T extends DateIntervalConsumer<T>> void declareIntervalFields(ObjectParser<T, String> parser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AGain, shouldn't this be T extends DateIntervalConsumer<?>>
? Am I not understanding this properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's one of these super-confusing recursive types. I think it's correct.
@@ -434,6 +434,7 @@ public static Aggregator buildWithoutAttemptedToAdaptToFilters( | |||
private final DocValueFormat format; | |||
protected final Range[] ranges; | |||
private final boolean keyed; | |||
@SuppressWarnings("rawtypes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it we don't just use wildcard types in these scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You get into the situation of ?
being different from ?
. It's a mess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few more comments.
@@ -100,7 +100,7 @@ | |||
/** | |||
* Sets the after value for this source. Values that compares smaller are filtered. | |||
*/ | |||
abstract void setAfter(Comparable value); | |||
abstract void setAfter(Comparable<?> value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Comparable<T>
IMO since this type is already generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done as you suggest, though all the implementations seem to handle arguments other than T
, so I'm not 100% sure it's correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see now. Looks like we are lenient here in places and will accept string values. Given that everything compiles though that must imply we're doing either casting or reflection to call this with other types somewhere. Should be fine given type erasure but if the implementations expect other types we should allow it at compile time I suppose 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked more carefully at how this method is called, and ended up reverting the wildcard replacement. It's "correct" given the implementations 🤷
@@ -158,7 +158,7 @@ public void collect(int doc, long bucket) throws IOException { | |||
} | |||
|
|||
@Override | |||
LeafBucketCollector getLeafCollector(Comparable value, LeafReaderContext context, LeafBucketCollector next) { | |||
LeafBucketCollector getLeafCollector(Comparable<?> value, LeafReaderContext context, LeafBucketCollector next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, we need to update this method on SingleDimensionValuesSource
to use the proper generic type argument instead of a wildcard. We probably have missed this in other areas as well. We should go back and check where we've used wildcards that there isn't already a proper type argument we should be using instead.
@@ -162,7 +162,7 @@ public void collect(int doc, long bucket) throws IOException { | |||
} | |||
|
|||
@Override | |||
LeafBucketCollector getLeafCollector(Comparable value, LeafReaderContext context, LeafBucketCollector next) { | |||
LeafBucketCollector getLeafCollector(Comparable<?> value, LeafReaderContext context, LeafBucketCollector next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, assuming we update SingleDimensionValuesSource
we should make this Comparable<BytesRef>
@elasticmachine update branch |
Part of #40366. Fix a number of javac issues when linting is enforced in `server/`.
Backported to |
Part of #40366. Fix a number of javac issues when linting is enforced in
server/
. Due to the number of issues that this surfaces, the fixes will be spread of multiple PRs.