{"record":{"id":"20529772b846a445","repo":"flowable/flowable-engine","slug":"type-is-null-205297","errorCode":null,"errorMessage":"type is null","messagePattern":"type is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/event/FlowableEventImpl.java","lineNumber":30,"sourceCode":" */\npackage org.flowable.common.engine.impl.event;\n\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.delegate.event.FlowableEvent;\nimport org.flowable.common.engine.api.delegate.event.FlowableEventType;\n\n/**\n * Base class for all {@link FlowableEvent} implementations.\n *\n * @author Filip Hrisafov\n */\npublic class FlowableEventImpl implements FlowableEvent {\n\n    protected FlowableEventType type;\n\n    public FlowableEventImpl(FlowableEventType type) {\n        if (type == null) {\n            throw new FlowableIllegalArgumentException(\"type is null\");\n        }\n\n        this.type = type;\n    }\n\n    @Override\n    public FlowableEventType getType() {\n        return type;\n    }\n\n    @Override\n    public String toString() {\n        return getClass() + \" - \" + type;\n    }\n}\n","sourceCodeStart":12,"sourceCodeEnd":46,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/event/FlowableEventImpl.java#L12-L46","documentation":"FlowableEventImpl is the base implementation of FlowableEvent and requires a non-null FlowableEventType. The type identifies what the event means, so constructing the event with null is treated as a programming error and FlowableIllegalArgumentException is thrown in the constructor.","triggerScenarios":"Calling new FlowableEventImpl(null) directly; generic event-creation code where the FlowableEventType variable is null (e.g. unresolved mapping from an external event name to an engine event type).","commonSituations":"Custom event dispatchers translating external messages to engine events where the type lookup returns null; test code building events without a type; switch/lookup tables missing a mapping for a new event type.","solutions":["Pass a valid FlowableEventType constant (e.g. from FlowableEngineEventType) when constructing the event.","Fix the type-resolution/mapping code so it never returns null — throw a clearer error there if the type is unknown.","Guard the call site and skip/replace the event when no type could be resolved."],"exampleFix":"// before\nFlowableEventType type = typeMap.get(externalName);\ndispatcher.dispatchEvent(new FlowableEventImpl(type));\n\n// after\nFlowableEventType type = typeMap.get(externalName);\nif (type != null) {\n    dispatcher.dispatchEvent(new FlowableEventImpl(type));\n}","handlingStrategy":"validation","validationCode":"FlowableEventType type = resolveType(externalName);\nif (type == null) {\n    throw new IllegalArgumentException(\"No FlowableEventType mapping for '\" + externalName + \"'\");\n}\ndispatcher.dispatchEvent(new FlowableEventImpl(type));","typeGuard":"boolean isKnownEventType(FlowableEventType t) { return t != null; }","tryCatchPattern":"try {\n    dispatcher.dispatchEvent(new FlowableEventImpl(type));\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"type is null\")) {\n        log.error(\"Event constructed without a FlowableEventType\");\n    }\n    throw e;\n}","preventionTips":["Use FlowableEngineEventType constants instead of ad-hoc type construction.","Ensure external-event-to-engine-type lookup tables are exhaustive and fail loudly on unknown values.","Wrap event factories with null-checks on the type parameter."],"tags":["events","null-check","constructor"],"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"}