mirror of https://github.com/apache/lucene.git
LUCENE-9661: Fix deadlock in TermsEnum.EMPTY
This commit is contained in:
parent
30aa0f5ba4
commit
eb24e95731
|
@ -298,6 +298,9 @@ Bug Fixes
|
||||||
* LUCENE-9642: When encoding triangles in ShapeField, make sure generated triangles are CCW by rotating
|
* LUCENE-9642: When encoding triangles in ShapeField, make sure generated triangles are CCW by rotating
|
||||||
triangle points before checking triangle orientation. (Ignacio Vera)
|
triangle points before checking triangle orientation. (Ignacio Vera)
|
||||||
|
|
||||||
|
* LUCENE-9661: Fix deadlock in TermsEnum.EMPTY that occurs when trying to initialize TermsEnum and BaseTermsEnum
|
||||||
|
at the same time (Namgyu Kim)
|
||||||
|
|
||||||
Other
|
Other
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,10 @@ public abstract class TermsEnum implements BytesRefIterator {
|
||||||
* of unused Attributes does not matter.
|
* of unused Attributes does not matter.
|
||||||
*/
|
*/
|
||||||
public static final TermsEnum EMPTY =
|
public static final TermsEnum EMPTY =
|
||||||
new BaseTermsEnum() {
|
new TermsEnum() {
|
||||||
|
|
||||||
|
private AttributeSource atts = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SeekStatus seekCeil(BytesRef term) {
|
public SeekStatus seekCeil(BytesRef term) {
|
||||||
return SeekStatus.END;
|
return SeekStatus.END;
|
||||||
|
@ -226,7 +229,15 @@ public abstract class TermsEnum implements BytesRefIterator {
|
||||||
|
|
||||||
@Override // make it synchronized here, to prevent double lazy init
|
@Override // make it synchronized here, to prevent double lazy init
|
||||||
public synchronized AttributeSource attributes() {
|
public synchronized AttributeSource attributes() {
|
||||||
return super.attributes();
|
if (atts == null) {
|
||||||
|
atts = new AttributeSource();
|
||||||
|
}
|
||||||
|
return atts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean seekExact(BytesRef text) throws IOException {
|
||||||
|
return seekCeil(text) == SeekStatus.FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue