{"record":{"id":"744593c8eb3ae876","repo":"flowable/flowable-engine","slug":"the-command-is-null-744593","errorCode":null,"errorMessage":"The command is null","messagePattern":"The command is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ManagementServiceImpl.java","lineNumber":423,"sourceCode":"        CommandConfig config = commandExecutor.getDefaultConfig().transactionNotSupported();\n        return commandExecutor.execute(config, new Command<>() {\n            @Override\n            public String execute(CommandContext commandContext) {\n                DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSession.class);\n                DbSqlSession dbSqlSession = new DbSqlSession(dbSqlSessionFactory, CommandContextUtil.getEntityCache(commandContext), connection, catalog,\n                        schema);\n                commandContext.getSessions().put(DbSqlSession.class, dbSqlSession);\n                ProcessEngineConfigurationImpl engineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n                engineConfiguration.getCommonSchemaManager().schemaUpdate();\n                return engineConfiguration.getSchemaManager().schemaUpdate();\n            }\n        });\n    }\n\n    @Override\n    public <T> T executeCommand(Command<T> command) {\n        if (command == null) {\n            throw new FlowableIllegalArgumentException(\"The command is null\");\n        }\n        return commandExecutor.execute(command);\n    }\n\n    @Override\n    public <T> T executeCommand(CommandConfig config, Command<T> command) {\n        if (config == null) {\n            throw new FlowableIllegalArgumentException(\"The config is null\");\n        }\n        if (command == null) {\n            throw new FlowableIllegalArgumentException(\"The command is null\");\n        }\n        return commandExecutor.execute(config, command);\n    }\n\n    @Override\n    public LockManager getLockManager(String lockName) {\n        return new LockManagerImpl(commandExecutor, lockName, getConfiguration().getLockPollRate(), configuration.getEngineCfgKey());","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ManagementServiceImpl.java#L405-L441","documentation":"ManagementServiceImpl.executeCommand runs an arbitrary Command through the engine's commandExecutor. The library throws FlowableIllegalArgumentException immediately when the command parameter is null, because there is nothing to execute and executing a null command would fail later with a less clear NPE. It is a fail-fast argument contract for the programmatic command API.","triggerScenarios":"Calling managementService.executeCommand(null), e.g. when the Command instance was built conditionally, returned null from a factory/helper method, or a variable holding the command was never initialized.","commonSituations":"Developers wrapping custom commands whose construction can fail and return null; refactoring that removed command instantiation; tests passing null to verify validation; Spring wiring issues leaving a command supplier returning null.","solutions":["Pass a non-null Command instance to executeCommand, e.g. managementService.executeCommand(new MyCustomCommand())","Check the code path producing the Command object for early returns of null or failed initialization","Null-check before calling: if (cmd != null) { ... executeCommand(cmd) }","Wrap the call in try-catch for FlowableIllegalArgumentException to surface a clear message in batch/admin tooling"],"exampleFix":"// before\nCommand<String> cmd = buildCommand(cfg); // may return null\nString result = managementService.executeCommand(cmd);\n// after\nCommand<String> cmd = buildCommand(cfg);\nif (cmd == null) {\n    throw new IllegalStateException(\"command could not be built\");\n}\nString result = managementService.executeCommand(cmd);","handlingStrategy":"type-guard","validationCode":"if (command == null) { throw new IllegalArgumentException(\"command must be provided\"); }\nmanagementService.executeCommand(command);","typeGuard":"boolean isValidCommand(Command<?> c) { return c != null; }","tryCatchPattern":"try {\n    T result = managementService.executeCommand(command);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid command argument: {}\", e.getMessage());\n}","preventionTips":["Never return null from command factories; throw with a descriptive message instead","Null-check command objects before invoking the management service","Keep command construction and execution close together to avoid uninitialized variables"],"tags":["java","flowable","null-argument","validation"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}