diff --git a/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 00c2c2437a2..8f0762b85b4 100644 --- a/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -311,7 +311,7 @@ public class NodeEnvironment extends AbstractComponent implements Closeable { * shard paths. The "write.lock" file is assumed to be under the shard * path's "index" directory as used by Elasticsearch. * - * @throws ElasticsearchException if any of the locks could not be acquired + * @throws LockObtainFailedException if any of the locks could not be acquired */ public static void acquireFSLockForPaths(@IndexSettings Settings indexSettings, Path... shardPaths) throws IOException { Lock[] locks = new Lock[shardPaths.length]; @@ -326,7 +326,7 @@ public class NodeEnvironment extends AbstractComponent implements Closeable { try { locks[i] = Lucene.acquireWriteLock(dirs[i]); } catch (IOException ex) { - throw new ElasticsearchException("unable to acquire " + + throw new LockObtainFailedException("unable to acquire " + IndexWriter.WRITE_LOCK_NAME + " for " + p); } } diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 9a43ec1faae..ea84f3ca178 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.shard; import org.apache.lucene.index.CorruptIndexException; +import org.apache.lucene.store.LockObtainFailedException; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.stats.IndexStats; @@ -110,7 +111,6 @@ public class IndexShardTests extends ElasticsearchSingleNodeTest { public void testLockTryingToDelete() throws Exception { createIndex("test"); ensureGreen(); - //IndicesService indicesService = getInstanceFromNode(IndicesService.class); NodeEnvironment env = getInstanceFromNode(NodeEnvironment.class); Path[] shardPaths = env.availableShardPaths(new ShardId("test", 0)); logger.info("--> paths: [{}]", shardPaths); @@ -118,7 +118,7 @@ public class IndexShardTests extends ElasticsearchSingleNodeTest { try { NodeEnvironment.acquireFSLockForPaths(Settings.EMPTY, shardPaths); fail("should not have been able to acquire the lock"); - } catch (ElasticsearchException e) { + } catch (LockObtainFailedException e) { assertTrue("msg: " + e.getMessage(), e.getMessage().contains("unable to acquire write.lock")); } // Test without the regular shard lock to assume we can acquire it @@ -128,7 +128,7 @@ public class IndexShardTests extends ElasticsearchSingleNodeTest { try { env.deleteShardDirectoryUnderLock(sLock, Settings.builder().build()); fail("should not have been able to delete the directory"); - } catch (ElasticsearchException e) { + } catch (LockObtainFailedException e) { assertTrue("msg: " + e.getMessage(), e.getMessage().contains("unable to acquire write.lock")); } }