code:     public void testLockTryingToDelete() throws Exception {
          String lockType = "native"; // test does not work with simple locks
          Settings nodeSettings = ImmutableSettings.builder()
                  .put("gateway.type", "local") // don't delete things!
                  .put("index.store.fs.fs_lock", lockType)
                  .build();
          String IDX = "test";
          logger.info("--> lock type: {}", lockType);
  
          internalCluster().startNode(nodeSettings);
          Settings idxSettings = ImmutableSettings.builder()
                  .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
                  .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
                  .put("index.store.fs.fs_lock", lockType)
                  .build();
  
          // only one node, so all primaries will end up on node1
          prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string,index=not_analyzed").get();
          ensureGreen(IDX);
          client().prepareIndex(IDX, "doc").setSource("foo", "bar").get();
          flushAndRefresh(IDX);
          NodeEnvironment env = internalCluster().getDataNodeInstance(NodeEnvironment.class);
          logger.info("--> data paths: [{}]", env.nodeDataPaths());
          Path[] shardPaths = env.shardDataPaths(new ShardId("test", 0), ImmutableSettings.builder().build());
          logger.info("--> paths: [{}]", shardPaths);
          // Should not be able to acquire the lock because it's already open
          try {
              NodeEnvironment.acquireFSLockForPaths(ImmutableSettings.EMPTY, shardPaths);
              fail("should not have been able to acquire the lock");
          } catch (ElasticsearchException 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
          // (worst case, meaning that the shard lock could be acquired and
          // we're green to delete the shard's directory)
          ShardLock sLock = new DummyShardLock(new ShardId("test", 0));
          try {
              env.deleteShardDirectoryUnderLock(sLock, ImmutableSettings.builder().build());
              fail("should not have been able to delete the directory");
          } catch (ElasticsearchException e) {
              assertTrue("msg: " + e.getMessage(), e.getMessage().contains("unable to acquire write.lock"));
          }
      }
  