public void setFetchAction(final FetchBuffer fetchBuffer) {
        final AtomicBoolean throwWakeupException = new AtomicBoolean(false);
        pendingTask.getAndUpdate(task -> {
            if (task == null) {
                return new FetchAction(fetchBuffer);
            } else if (task instanceof WakeupFuture) {
                throwWakeupException.set(true);
                return null;
            } else if (task instanceof DisabledWakeups) {
                return task;
            }
            // last active state is still active
            throw new IllegalStateException("Last active task is still active");
        });
        if (throwWakeupException.get()) {
            throw new WakeupException();
        }
    }
If there is no pending task, set the pending task active.
    If wakeup was called before setting an active task, the current task will complete exceptionally with
    WakeupException right
    away.
    if there is an active task, throw exception.
@param currentTask
@param <T>
@return
clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java