PersistentLockManager implements AutoCloseable { public synchronized void shutdown() { log.info("Shutting down..."); try { isShutDown = true; while (lockId != null) { releasePersistentLock(); } log.info("Shutdown completed!"); } catch (Exception e) { logFailedShutdown(e); } } PersistentLockManager(MetricsManager metricsManager,
            PersistentLockService persistentLockService, long persistentLockRetryWaitMillis); @Override void close(); synchronized void shutdown(); void acquirePersistentLockWithRetry(); synchronized void releasePersistentLock();  }
@Test public void shutdownWithoutAcquireIsNoOp() { manager.shutdown(); verifyZeroInteractions(mockPls); }
@Test(timeout = 10_000) @SuppressWarnings("FutureReturnValueIgnored") public void doesNotDeadlockOnShutdownIfLockCannotBeAcquired() throws InterruptedException { CountDownLatch acquireStarted = new CountDownLatch(1); when(mockPls.acquireBackupLock(any())).then(inv -> { acquireStarted.countDown(); throw new CheckAndSetException("foo"); }); executor.execute(manager::acquirePersistentLockWithRetry); acquireStarted.await(); manager.shutdown(); }