You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2022/07/21 10:36:04 UTC

[lucene] branch branch_9x updated: LUCENE-10583: Add docstring warning to not lock on Lucene objects (#963)

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 1884a8730a3 LUCENE-10583: Add docstring warning to not lock on Lucene objects (#963)
1884a8730a3 is described below

commit 1884a8730a315e1e51e6ad0b43774e6714a3b9d1
Author: Vigya Sharma <vi...@gmail.com>
AuthorDate: Thu Jul 21 03:35:17 2022 -0700

    LUCENE-10583: Add docstring warning to not lock on Lucene objects (#963)
    
    * add locking warning to docstring
    
    * git tidy
---
 lucene/core/src/java/org/apache/lucene/store/Directory.java     | 4 ++++
 lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/lucene/core/src/java/org/apache/lucene/store/Directory.java b/lucene/core/src/java/org/apache/lucene/store/Directory.java
index bacf2d1681b..a94b906e22a 100644
--- a/lucene/core/src/java/org/apache/lucene/store/Directory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/Directory.java
@@ -40,6 +40,10 @@ import org.apache.lucene.util.IOUtils;
  *       java.nio.file.FileAlreadyExistsException}.
  * </ul>
  *
+ * <p><b>NOTE:</b> If your application requires external synchronization, you should <b>not</b>
+ * synchronize on the <code>Directory</code> implementation instance as this may cause deadlock; use
+ * your own (non-Lucene) objects instead.
+ *
  * @see FSDirectory
  * @see ByteBuffersDirectory
  * @see FilterDirectory
diff --git a/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java b/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
index 5c20055c802..25ed27efcbe 100644
--- a/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
@@ -77,6 +77,10 @@ import org.apache.lucene.util.SuppressForbidden;
  * Thread#interrupt()} or {@link Future#cancel(boolean)} you should use the legacy {@code
  * RAFDirectory} from the Lucene {@code misc} module in favor of {@link MMapDirectory}.
  *
+ * <p><b>NOTE:</b> If your application requires external synchronization, you should <b>not</b>
+ * synchronize on the <code>MMapDirectory</code> instance as this may cause deadlock; use your own
+ * (non-Lucene) objects instead.
+ *
  * @see <a href="http://blog.thetaphi.de/2012/07/use-lucenes-mmapdirectory-on-64bit.html">Blog post
  *     about MMapDirectory</a>
  */