flowable/flowable-engine · error · FlowableIllegalArgumentException

event consumer is null.

Error message

event consumer is null.

What it means

RemoveEventConsumerCommand removes a FlowableEventRegistryEventConsumer from the event registry via the engine command stack. The command validates its constructor argument and throws FlowableIllegalArgumentException if the event consumer is null. This is a programmer-error guard: a null consumer can never be removed meaningfully.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/RemoveEventConsumerCommand.java:32

import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.eventregistry.api.EventRegistryEventConsumer;

public class RemoveEventConsumerCommand implements Command<Void> {

    protected EventRegistryEventConsumer eventConsumer;

    public RemoveEventConsumerCommand(EventRegistryEventConsumer eventConsumer) {
        this.eventConsumer = eventConsumer;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (eventConsumer == null) {
            throw new FlowableIllegalArgumentException("event consumer is null.");
        }

        CommandContextUtil.getEventRegistry().removeFlowableEventRegistryEventConsumer(eventConsumer);

        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Ensure the FlowableEventRegistryEventConsumer instance is non-null before calling removeEventConsumer; keep the reference returned when the consumer was created/registered.
  2. Add a null check or Objects.requireNonNull around the consumer in calling code and skip removal when it was never created.
  3. Fix the code path that fails to initialize the consumer (e.g. registration exception swallowed earlier) so removal operates on a real object.

Example fix

// before
runtimeService.removeEventConsumer(consumer); // consumer may be null
// after
if (consumer != null) {
    runtimeService.removeEventConsumer(consumer);
}
Defensive patterns

Strategy: type-guard

Type guard

boolean isRemovable(FlowableEventRegistryEventConsumer consumer) {
    return consumer != null;
}

Try / catch

try {
    runtimeService.removeEventConsumer(consumer);
} catch (FlowableIllegalArgumentException e) {
    // consumer was null; nothing to remove
}

Prevention

When it happens

Trigger: Calling runtimeService.removeEventConsumer(null) (or constructing RemoveEventConsumerCommand with a null FlowableEventRegistryEventConsumer), typically when the variable holding the consumer was never initialized or was already resolved to null.

Common situations: Storing event consumers in a map/collection and passing a lookup result that returned null; a refactored code path that stopped creating the consumer before removal; cleanup code in a shutdown hook where the consumer registration failed earlier and the reference stayed null.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/806ed3176bb90557. Report an issue: GitHub.