uschindler commented on code in PR #12199: URL: https://github.com/apache/lucene/pull/12199#discussion_r1133798472
########## lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java: ########## @@ -113,15 +113,17 @@ private synchronized DocumentsWriterPerThread newWriter() { * operation (add/updateDocument). */ DocumentsWriterPerThread getAndLock() { - synchronized (this) { - ensureOpen(); - DocumentsWriterPerThread dwpt = freeList.poll(DocumentsWriterPerThread::tryLock); - if (dwpt == null) { - dwpt = newWriter(); - } - // DWPT is already locked before return by this method: - return dwpt; + ensureOpen(); + DocumentsWriterPerThread dwpt = freeList.poll(DocumentsWriterPerThread::tryLock); + if (dwpt == null) { + // newWriter() adds the DWPT to the `dwpts` set as a side-effect. However it is not added to + // `freeList` at this point, it will be added later on once DocumentsWriter has indexed a + // document into this DWPT and then gives it back to the pool by calling + // #marksAsFreeAndUnlock. + dwpt = newWriter(); Review Comment: It was a joke! My intention was the first comment, to invert the if logic so use "return on success" -- 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