Skip to content

Commit d8b1c23

Browse files
author
Christoph Büscher
authored
Remove Comparable interface from ScoreAccessor (#35519)
The way ScoreAccessor implements `compareTo()` is problematic because it doesn't completely follow the Comparable contract, specificaly symmetry (if x is a ScoreAccessor and y any Number then x.comparTo(y) works, but y.compareTo(x) generally does not even compile). Fortunately we don't seem to use the fact that ScoreAccessor is a Comparable anywhere, so we can simply remove it.
1 parent 603d1a4 commit d8b1c23

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

server/src/main/java/org/elasticsearch/script/ScoreAccessor.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* The provided {@link DocLookup} is used to retrieve the score
3131
* for the current document.
3232
*/
33-
public final class ScoreAccessor extends Number implements Comparable<Number> {
33+
public final class ScoreAccessor extends Number {
3434

3535
Scorable scorer;
3636

@@ -65,9 +65,4 @@ public float floatValue() {
6565
public double doubleValue() {
6666
return score();
6767
}
68-
69-
@Override
70-
public int compareTo(Number o) {
71-
return Float.compare(this.score(), o.floatValue());
72-
}
7368
}

0 commit comments

Comments
 (0)