apache / apache/lucene

Design: TaskSequence.REPEAT_EXHAUST is mutable

Open
#14,151 0 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

(Found during reviewing code while porting to the [Lucene.NET](https://github.com/apache/lucenenet/) project.)

The static [`TaskSequence.REPEAT_EXHAUST`](https://github.com/apache/lucene/blob/dce24c8621748d51954c4845eab7626dae166db9/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java#L33) field has been perhaps accidentally left as a mutable static field. It appears that this field is only ever used a sentinel value that is not intended to be mutated, and should be marked `final`. As far as I can tell, there is no justification to have this field be mutable. Although this is just benchmark code, and thus I'm sure very low priority, it could potentially result in bugs if it is mutated during execution.

### Version and environment details

Affects Lucene 4.0.0 through current (10.1.0)

Contributor guide

Open the contributing guide

Research direction

Open lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java and inspect the declaration of TaskSequence.REPEAT_EXHAUST. Confirm it is used only as a sentinel, then make the declaration immutable and verify that the benchmark module still builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.