int decreaseAndGet(final WorkerResourceSpec workerResourceSpec) {
        final Integer newValue =
                workerNums.compute(
                        Preconditions.checkNotNull(workerResourceSpec),
                        (ignored, num) -> {
                            Preconditions.checkState(
                                    num != null && num > 0,
                                    "Cannot decrease, no worker of spec %s.",
                                    workerResourceSpec);
                            return num == 1 ? null : num - 1;
                        });
        return newValue != null ? newValue : 0;
    }
@Test
    void testWorkerCounterDecreaseOnZero() {
        final WorkerResourceSpec spec = new WorkerResourceSpec.Builder().build();
        final WorkerCounter counter = new WorkerCounter();
        assertThatThrownBy(() -> counter.decreaseAndGet(spec))
                .isInstanceOf(IllegalStateException.class);
    }