{"record":{"id":"08efa0d82daafc59","repo":"flowable/flowable-engine","slug":"the-event-listener-to-be-removed-must-not-be-null","errorCode":null,"errorMessage":"The event listener to be removed must not be null.","messagePattern":"The event listener to be removed must not be null\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveEventListenerCommand.java","lineNumber":38,"sourceCode":"\n/**\n * This command removes an event listener from the case engine.\n *\n * @author Micha Kiener\n */\npublic class RemoveEventListenerCommand implements Command<Void> {\n\n    protected FlowableEventListener listener;\n\n    public RemoveEventListenerCommand(FlowableEventListener listener) {\n        super();\n        this.listener = listener;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (listener == null) {\n            throw new FlowableIllegalArgumentException(\"The event listener to be removed must not be null.\");\n        }\n\n        CommandContextUtil.getCmmnEngineConfiguration(commandContext).getEventDispatcher().removeEventListener(listener);\n\n        return null;\n    }\n}\n","sourceCodeStart":20,"sourceCodeEnd":46,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveEventListenerCommand.java#L20-L46","documentation":"Thrown as FlowableIllegalArgumentException by RemoveEventListenerCommand when the FlowableEventListener passed to be removed is null. It is a simple null-guard before delegating to the CMMN engine's event dispatcher.","triggerScenarios":"Calling CmmnEngineConfiguration.eventDispatcher / removeEventListener (or the cmmnEngine configuration API wrapping it) with a null listener reference, e.g. an unassigned field or a lookup that returned null.","commonSituations":"DI/field never initialized; a getListener() that returned null; mistakenly removing a listener that was never registered (retained a null handle).","solutions":["Ensure the listener instance is non-null and the same object that was added before calling removeEventListener","Add an explicit null check in the calling code and skip removal when absent","Fix the code path producing the null listener (e.g. registry lookup returning null)"],"exampleFix":"// before\ncmmnEngineConfiguration.removeEventListener(listener); // listener may be null\n// after\nif (listener != null) {\n    cmmnEngineConfiguration.removeEventListener(listener);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean removable = listener != null;","tryCatchPattern":"try { cmmnEngineConfiguration.removeEventListener(listener); }\ncatch (FlowableIllegalArgumentException e) { /* listener was null — nothing to remove */ }","preventionTips":["Keep strong references to registered listeners","Skip removal when the reference is null","Return the same listener instance from registration for later removal"],"tags":["null","listener","event-dispatcher","argument"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}