Skip to content

Use List.of() instead of Collections.unmodifiableList(Arrays.asList()) in BooleanQuery#15821

Open
sgup432 wants to merge 1 commit intoapache:mainfrom
sgup432:boolean_query_listOf
Open

Use List.of() instead of Collections.unmodifiableList(Arrays.asList()) in BooleanQuery#15821
sgup432 wants to merge 1 commit intoapache:mainfrom
sgup432:boolean_query_listOf

Conversation

@sgup432
Copy link
Contributor

@sgup432 sgup432 commented Mar 13, 2026

Description

While checking BooleanQuery, I saw in the constructor we wrap the clauses in two objects: Arrays$ArrayList (via Arrays.asList) then UnmodifiableList (via Collections.unmodifiableList) like below:

this.clauses = Collections.unmodifiableList(Arrays.asList(clauses));

Doesn't make sense to me if we can simply do List.of()? Which returns a immutable list as well with no wrapper overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant