mirror of https://github.com/apache/lucene.git
LUCENE-9084: fix potential deadlock due to circular synchronization in AnalyzingInfixSuggester
This commit is contained in:
parent
08b64aab8f
commit
deba7d1404
|
@ -120,7 +120,8 @@ Optimizations
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------------------
|
---------------------
|
||||||
(No changes)
|
|
||||||
|
* LUCENE-9084: Fix potential deadlock due to circular synchronization in AnalyzingInfixSuggester (Paul Ward)
|
||||||
|
|
||||||
Other
|
Other
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
@ -368,15 +368,16 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void ensureOpen() throws IOException {
|
private void ensureOpen() throws IOException {
|
||||||
if (writer == null) {
|
synchronized (searcherMgrLock) {
|
||||||
if (DirectoryReader.indexExists(dir)) {
|
if (writer == null) {
|
||||||
// Already built; open it:
|
if (DirectoryReader.indexExists(dir)) {
|
||||||
writer = new IndexWriter(dir, getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.APPEND));
|
// Already built; open it:
|
||||||
} else {
|
writer = new IndexWriter(dir, getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.APPEND));
|
||||||
writer = new IndexWriter(dir, getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.CREATE));
|
} else {
|
||||||
}
|
writer = new IndexWriter(dir, getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.CREATE));
|
||||||
synchronized (searcherMgrLock) {
|
}
|
||||||
|
|
||||||
SearcherManager oldSearcherMgr = searcherMgr;
|
SearcherManager oldSearcherMgr = searcherMgr;
|
||||||
searcherMgr = new SearcherManager(writer, null);
|
searcherMgr = new SearcherManager(writer, null);
|
||||||
if (oldSearcherMgr != null) {
|
if (oldSearcherMgr != null) {
|
||||||
|
|
Loading…
Reference in New Issue