@Test
public void testSynchronizeWithExceptionInTask() {

    Lock[] locks = new Lock[10];
    for (int i = 0; i < locks.length; i++)
        locks[i] = mock(Lock.class);
    RuntimeException ex = new RuntimeException();
    try {
        DefaultModelStorage.synchronize(() -> { throw ex; }, locks);
        fail();
    }
    catch (RuntimeException e) {
        assertEquals(ex, e);
    }
    for (Lock lock : locks) {
        verify(lock, times(1)).lock();
        verify(lock, times(1)).unlock();
        verifyNoMoreInteractions(lock);
    }
}