Skip to content

UnsupportedOperationException instead of IllegalArgumentException from PointInSetQuery when values are out of order #14161

@jhinch-at-atlassian-com

Description

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:

          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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions