jpountz commented on code in PR #12199: URL: https://github.com/apache/lucene/pull/12199#discussion_r1132726733
########## lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java: ########## @@ -113,15 +113,19 @@ private synchronized DocumentsWriterPerThread newWriter() { * operation (add/updateDocument). */ DocumentsWriterPerThread getAndLock() { - synchronized (this) { - ensureOpen(); - DocumentsWriterPerThread dwpt = freeList.poll(DocumentsWriterPerThread::tryLock); - if (dwpt == null) { - dwpt = newWriter(); + ensureOpen(); + DocumentsWriterPerThread dwpt = freeList.poll(DocumentsWriterPerThread::tryLock); + if (dwpt == null) { Review Comment: Thanks for sharing this blog post, I remember reading it in the past, it was a good re-read. I mentioned polls because I thought that they were what made you think that this code is a case of double-checked locking, as there is a first call before the lock and another one under the lock, like the null checks with double-checked locking with singletons. I need to go on weekend, I'll try to post a convincing explanation of why this is not a case of double-checked locking and why it is safe next week. By the way, thanks for looking! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org