apache / apache/lucene

Make SortField immutable

Open
#15,480 2 comments 1 reaction 1 assignee Claimed by @romseygeek View on GitHub
type:task
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

`Sort` objects are shallowly immutable, but their inner `SortField` implementations are not, which could cause hard-to-track down bugs. We should make `SortField` immutable as well.

The `field`, `type` and `reverse` fields can be made final with no change in API. Missing values are trickier, as they are currently mutable via a `setMissingValue` method. My suggestion would be to deprecate this method in 10.4, and add constructors that explicitly take missing values (which could also enhance type safety); and then remove the method in 11.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.