You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/08/25 16:37:58 UTC
lucene-solr:master: remove deprecated IndexWriter.isLocked()
Repository: lucene-solr
Updated Branches:
refs/heads/master ada714972 -> d489b8c05
remove deprecated IndexWriter.isLocked()
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d489b8c0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d489b8c0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d489b8c0
Branch: refs/heads/master
Commit: d489b8c05ddbd9c5b4f0a2a0b20439a9c5b64736
Parents: ada7149
Author: Robert Muir <rm...@apache.org>
Authored: Thu Aug 25 12:34:38 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Thu Aug 25 12:34:38 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/index/IndexWriter.java | 18 ------------------
.../src/java/org/apache/solr/core/SolrCore.java | 20 +++++++++++++++++++-
2 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d489b8c0/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 0fb23d9..7abf681 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -4685,24 +4685,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
testPoint("finishStartCommit");
}
- /**
- * Returns <code>true</code> iff the index in the named directory is
- * currently locked.
- * @param directory the directory to check for a lock
- * @throws IOException if there is a low-level IO error
- * @deprecated Use of this method can only lead to race conditions. Try
- * to actually obtain a lock instead.
- */
- @Deprecated
- public static boolean isLocked(Directory directory) throws IOException {
- try {
- directory.obtainLock(WRITE_LOCK_NAME).close();
- return false;
- } catch (LockObtainFailedException failed) {
- return true;
- }
- }
-
/** If {@link DirectoryReader#open(IndexWriter)} has
* been called (ie, this writer is in near real-time
* mode), then after a merge completes, this class can be
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d489b8c0/solr/core/src/java/org/apache/solr/core/SolrCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 2704e4a..90bcd34 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -549,6 +549,24 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
// protect via synchronized(SolrCore.class)
private static Set<String> dirs = new HashSet<>();
+ /**
+ * Returns <code>true</code> iff the index in the named directory is
+ * currently locked.
+ * @param directory the directory to check for a lock
+ * @throws IOException if there is a low-level IO error
+ * @deprecated Use of this method can only lead to race conditions. Try
+ * to actually obtain a lock instead.
+ */
+ @Deprecated
+ private static boolean isWriterLocked(Directory directory) throws IOException {
+ try {
+ directory.obtainLock(IndexWriter.WRITE_LOCK_NAME).close();
+ return false;
+ } catch (LockObtainFailedException failed) {
+ return true;
+ }
+ }
+
void initIndex(boolean reload) throws IOException {
String indexDir = getNewIndexDir();
@@ -564,7 +582,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
final String lockType = getSolrConfig().indexConfig.lockType;
Directory dir = directoryFactory.get(indexDir, DirContext.DEFAULT, lockType);
try {
- if (IndexWriter.isLocked(dir)) {
+ if (isWriterLocked(dir)) {
log.error(logid + "Solr index directory '{}' is locked (lockType={}). Throwing exception.",
indexDir, lockType);
throw new LockObtainFailedException