You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by na...@apache.org on 2021/01/15 21:49:38 UTC
[lucene-solr] branch master updated: LUCENE-9661: Fix deadlock in
TermsEnum.EMPTY
This is an automated email from the ASF dual-hosted git repository.
namgyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new eb24e95 LUCENE-9661: Fix deadlock in TermsEnum.EMPTY
eb24e95 is described below
commit eb24e95731b9f865b95b821c1745264fdc58119d
Author: Namgyu Kim <na...@apache.org>
AuthorDate: Sat Jan 16 06:49:23 2021 +0900
LUCENE-9661: Fix deadlock in TermsEnum.EMPTY
---
lucene/CHANGES.txt | 3 +++
.../core/src/java/org/apache/lucene/index/TermsEnum.java | 15 +++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index dfb4efa..7affde9 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -298,6 +298,9 @@ Bug Fixes
* LUCENE-9642: When encoding triangles in ShapeField, make sure generated triangles are CCW by rotating
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
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java b/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
index 0f03c94..de0234b 100644
--- a/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
+++ b/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
@@ -180,7 +180,10 @@ public abstract class TermsEnum implements BytesRefIterator {
* of unused Attributes does not matter.
*/
public static final TermsEnum EMPTY =
- new BaseTermsEnum() {
+ new TermsEnum() {
+
+ private AttributeSource atts = null;
+
@Override
public SeekStatus seekCeil(BytesRef term) {
return SeekStatus.END;
@@ -226,7 +229,15 @@ public abstract class TermsEnum implements BytesRefIterator {
@Override // make it synchronized here, to prevent double lazy init
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