You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PointInSetQuery in its constructor will check if the values provided to it are in order and if not will attempt to throw an exception:
throw new IllegalArgumentException(
"values are out of order: saw " + previous + " before " + current);
However instead of this exception, the following exception is thrown:
java.lang.UnsupportedOperationException
at org.apache.lucene.util.BytesRefBuilder.hashCode(BytesRefBuilder.java:172)
at java.base/java.lang.Object.toString(Object.java:256)
at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:453)
at org.apache.lucene.search.PointInSetQuery.<init>(PointInSetQuery.java:116)
This is because previous is a BytesRefBuilder which does not support the hashCode() method which is used by the default toString() method.
Either BytesRefBuilder should be updated to allow for toString() to be invoked on it or the code should be modified to retrieve the BytesRef within the BytesRefBuilder so that the correct exception is thrown
Version and environment details
JDK 21
Lucene 9.11.1
The text was updated successfully, but these errors were encountered:
Oh gross. Good catch! It seems like the desire in this exception message is to print out the previous bytes ref in the same was as current. I wonder if we should implement BytesRefBuilder#toString to delegate to its underlying ref buffer?
Having BytesRefBuilder#toString delegate to its underlying buffer or calling BytesRefBuilder#get within PointInSetQuery both seem like reasonable options.
@jhinch-at-atlassian-com agreed. I might lean towards implementing a BytesRefBuilder#toString method since it could potentially help in other places where this trappy behavior might happen. Do you have any interest in opening a pull request? I'd be happy to review it.
Description
PointInSetQuery in its constructor will check if the values provided to it are in order and if not will attempt to throw an exception:
However instead of this exception, the following exception is thrown:
This is because
previous
is aBytesRefBuilder
which does not support thehashCode()
method which is used by the defaulttoString()
method.Either
BytesRefBuilder
should be updated to allow fortoString()
to be invoked on it or the code should be modified to retrieve theBytesRef
within theBytesRefBuilder
so that the correct exception is thrownVersion and environment details
The text was updated successfully, but these errors were encountered: