public boolean tryLock() {
    try {
      lockRandomAccessFile = new RandomAccessFile(lockFilePath.toFile(), "rw");
      lockChannel = lockRandomAccessFile.getChannel();
      lockFile = lockChannel.tryLock(0, 1024, false);

      return lockFile != null;
    } catch (IOException e) {
      throw new IllegalStateException("Failed to create lock in " + lockFilePath.toString(), e);
    }
  }
@Test
  public void errorTryLock() {
    lock = new DirectoryLock(Paths.get("non", "existing", "path"));

    assertThatThrownBy(() -> lock.tryLock())
      .isInstanceOf(IllegalStateException.class)
      .hasMessageContaining("Failed to create lock");
  }