Skip to content

Commit

Permalink
HSEARCH-4983 Fix lock bypass in IndexWriterProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Sep 29, 2023
1 parent 71777e4 commit a8823c5
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ public IndexWriterProvider(String indexName, EventContext eventContext,
* Should be used when stopping the index.
*/
public void clear() throws IOException {
IndexWriterDelegatorImpl indexWriterDelegator = currentWriter.getAndSet( null );
if ( indexWriterDelegator != null ) {
indexWriterDelegator.close();
currentWriterModificationLock.lock();
try {
IndexWriterDelegatorImpl indexWriterDelegator = currentWriter.getAndSet( null );
if ( indexWriterDelegator != null ) {
indexWriterDelegator.close();
}
}
finally {
currentWriterModificationLock.unlock();
}
}

Expand Down

0 comments on commit a8823c5

Please sign in to comment.