@Test public void testCloseAllLocksOneThrowing() { List<DistributedLock> locks = new ArrayList<>(); for (int i = 0; i < 4; i++) { locks.add(new DummyLock()); } locks.add(new ThrowingLock()); for (int i = 0; i < 5; i++) { locks.add(new DummyLock()); } new LockCollection(locks).close(); for (DistributedLock lock : locks) { if (lock instanceof DummyLock) { assertThat(((DummyLock) lock).closed).isTrue(); } } }
@Override public void close() { for (LockFactory.DistributedLock lock : myLocks) { try { lock.close(); } catch (Exception e) { LOG.warn("Unable to release lock {} ", lock, e); } } }
LockCollection implements LockFactory.DistributedLock { @Override public void close() { for (LockFactory.DistributedLock lock : myLocks) { try { lock.close(); } catch (Exception e) { LOG.warn("Unable to release lock {} ", lock, e); } } } }
LockCollection implements LockFactory.DistributedLock { @Override public void close() { for (LockFactory.DistributedLock lock : myLocks) { try { lock.close(); } catch (Exception e) { LOG.warn("Unable to release lock {} ", lock, e); } } } LockCollection(Collection<? extends LockFactory.DistributedLock> locks); }
LockCollection implements LockFactory.DistributedLock { @Override public void close() { for (LockFactory.DistributedLock lock : myLocks) { try { lock.close(); } catch (Exception e) { LOG.warn("Unable to release lock {} ", lock, e); } } } LockCollection(Collection<? extends LockFactory.DistributedLock> locks); @Override void close(); }
LockCollection implements LockFactory.DistributedLock { @Override public void close() { for (LockFactory.DistributedLock lock : myLocks) { try { lock.close(); } catch (Exception e) { LOG.warn("Unable to release lock {} ", lock, e); } } } LockCollection(Collection<? extends LockFactory.DistributedLock> locks); @Override void close();  }