From 25a842d87198af7b930d890a93b63093d9ca93c3 Mon Sep 17 00:00:00 2001 From: Vigya Sharma Date: Thu, 21 Jul 2022 03:35:17 -0700 Subject: [PATCH] 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 ++++ .../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}. * * + *

NOTE: If your application requires external synchronization, you should not + * synchronize on the Directory 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 f31a3a1f880..fa2dd16385e 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}. * + *

NOTE: If your application requires external synchronization, you should not + * synchronize on the MMapDirectory instance as this may cause deadlock; use your own + * (non-Lucene) objects instead. + * * @see Blog post * about MMapDirectory */