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 a90d44f39a6..d98f393e4df 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -224,7 +224,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit { private Map segmentsToMerge = new HashMap(); private int mergeMaxNumSegments; - protected Lock writeLock; + private Lock writeLock; private volatile boolean closed; private volatile boolean closing; diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java index 72493a322be..525a7ce8748 100644 --- a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java +++ b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java @@ -150,17 +150,11 @@ public class SolrIndexWriter extends IndexWriter { log.error("Error closing IndexWriter, trying rollback", t); super.rollback(); } - if (writeLock != null && writeLock.isLocked()) { + if (IndexWriter.isLocked(directory)) { try { - // we go right to the lock because - // IndexWriter#unlock(Directory) does - // not work well in this case with - // native locks - writeLock.release(); + IndexWriter.unlock(directory); } catch (Throwable t) { - log.error( - "Coud not unlock directory after seemingly failed IndexWriter#close()", - t); + log.error("Coud not unlock directory after seemingly failed IndexWriter#close()", t); } } break;