LockHandler implements Lock { public boolean isHeldByCurrentThread() { return lock.isHeldByCurrentThread(); } private  LockHandler(ReentrantLock lock); void run(@Nonnull Runnable runnable); void runChecked(@Nonnull CheckedRunnable<E> runnable); void runInterruptibly(@Nonnull Runnable runnable); U call(@Nonnull Supplier<U> supplier); U callChecked(CheckedSupplier<U,E> supplier); U callInterruptibly(Supplier<U> supplier); boolean isLocked(); boolean isHeldByCurrentThread(); @Nonnull static LockHandler newReentrantLock(); @Override void lock(); @Override void lockInterruptibly(); @Override boolean tryLock(); @Override boolean tryLock(long time, @NotNull TimeUnit unit); @Override void unlock(); @NotNull @Override Condition newCondition();  }
@Test(timeout = 5000) public void isHeldByCurrentThread() { LockHandler lock = LockHandler.newReentrantLock(); assertThat(lock.isHeldByCurrentThread()).isFalse(); lock.run(() -> assertThat(lock.isHeldByCurrentThread()).isTrue()); assertThat(lock.isHeldByCurrentThread()).isFalse(); }