@Test void shouldExecuteWithResult() throws Throwable { when(lockProvider.lock(lockConfig)) .thenReturn(Optional.of(mock(SimpleLock.class))); TaskResult<String> result = executor.executeWithLock(() -> "result", lockConfig); assertThat(result.wasExecuted()).isTrue(); assertThat(result.getResult()).isEqualTo("result"); }
@Override public void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig) { try { executeWithLock((Task) task::run, lockConfig); } catch (RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new IllegalStateException(throwable); } }
DefaultLockingTaskExecutor implements LockingTaskExecutor { @Override public void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig) { try { executeWithLock((Task) task::run, lockConfig); } catch (RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } }
DefaultLockingTaskExecutor implements LockingTaskExecutor { @Override public void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig) { try { executeWithLock((Task) task::run, lockConfig); } catch (RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } DefaultLockingTaskExecutor(@NonNull LockProvider lockProvider); }
DefaultLockingTaskExecutor implements LockingTaskExecutor { @Override public void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig) { try { executeWithLock((Task) task::run, lockConfig); } catch (RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } DefaultLockingTaskExecutor(@NonNull LockProvider lockProvider); @Override void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig); @Override void executeWithLock(@NonNull Task task, @NonNull LockConfiguration lockConfig); @Override @NonNull TaskResult<T> executeWithLock(@NonNull TaskWithResult<T> task, @NonNull LockConfiguration lockConfig); }
DefaultLockingTaskExecutor implements LockingTaskExecutor { @Override public void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig) { try { executeWithLock((Task) task::run, lockConfig); } catch (RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } DefaultLockingTaskExecutor(@NonNull LockProvider lockProvider); @Override void executeWithLock(@NonNull Runnable task, @NonNull LockConfiguration lockConfig); @Override void executeWithLock(@NonNull Task task, @NonNull LockConfiguration lockConfig); @Override @NonNull TaskResult<T> executeWithLock(@NonNull TaskWithResult<T> task, @NonNull LockConfiguration lockConfig);  }