{"record":{"id":"e52047c68699006b","repo":"quarkusio/quarkus","slug":"the-command-line-cannot-be-null","errorCode":null,"errorMessage":"the command line cannot be null.","messagePattern":"the command line cannot be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/MavenProcessInvoker.java","lineNumber":88,"sourceCode":"            result.setProcess(process);\n        } catch (CommandLineException e) {\n            result.setException(e);\n        }\n\n        return result;\n    }\n\n    private Process executeCommandLine(Commandline cli, InvocationRequest request)\n            throws CommandLineException {\n        InvocationOutputHandler outputHandler = request.getOutputHandler(this.outputHandler);\n        InvocationOutputHandler errorHandler = request.getErrorHandler(this.errorHandler);\n        return executeCommandLine(cli, outputHandler, errorHandler);\n    }\n\n    private static Process executeCommandLine(Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr)\n            throws CommandLineException {\n        if (cl == null) {\n            throw new IllegalArgumentException(\"the command line cannot be null.\");\n        } else {\n            final Process p = cl.execute();\n            final StreamPumper outputPumper = new StreamPumper(p.getInputStream(), systemOut);\n            final StreamPumper errorPumper = new StreamPumper(p.getErrorStream(), systemErr);\n\n            outputPumper.start();\n            errorPumper.start();\n\n            new Thread(() -> {\n                try {\n                    // Wait for termination\n                    p.waitFor();\n                    outputPumper.waitUntilDone();\n                    errorPumper.waitUntilDone();\n                } catch (Exception e) {\n                    outputPumper.disable();\n                    errorPumper.disable();\n                    e.printStackTrace();","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/MavenProcessInvoker.java#L70-L106","documentation":"MavenProcessInvoker's private executeCommandLine(Commandline cl, ...) throws IllegalArgumentException(\"the command line cannot be null.\") when the resolved Commandline is null. This is an internal defensive check: it fires only if a null cli reached the process-spawning overload, meaning the CLI was never built successfully yet execution proceeded. Callers normally see the sibling MavenInvocationException (error 4081) instead.","triggerScenarios":"A code path in MavenProcessInvoker where cli resolution (executeCommandLine(cli, outputHandler, errorHandler) delegating to the 3-arg overload) receives null — i.e. invoking executeCommandLine directly with a null Commandline after a failed/unperformed cliBuilder.build().","commonSituations":"Custom subclasses or forks of MavenProcessInvoker that call executeCommandLine with an unbuilt cli; refactoring mistakes where build failure handling is bypassed; reflection-based test harnesses passing null.","solutions":["Ensure MavenProcessInvoker.execute() is used to launch Maven so cli is always built (or MavenInvocationException thrown) before executeCommandLine runs.","Null-check the Commandline before invoking executeCommandLine and fail fast with a clear message.","If building the CLI yourself, verify cliBuilder.build(request) returned non-null and handle CommandLineConfigurationException."],"exampleFix":"// before\nProcess p = invoker.executeCommandLine(null, out, err);\n// after\nCommandline cli = cliBuilder.build(request);\nObjects.requireNonNull(cli, \"Maven CLI command line was not built\");\nProcess p = invoker.executeCommandLine(cli, out, err);","handlingStrategy":"validation","validationCode":"if (cli == null) {\n    throw new IllegalArgumentException(\"CLI must be built via cliBuilder.build(request) before executeCommandLine\");\n}","typeGuard":"boolean hasCli(Commandline cl) {\n    return cl != null;\n}","tryCatchPattern":"try {\n    Process p = executeCommandLine(cl, out, err);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"No command line configured for Maven invocation\", e);\n}","preventionTips":["Always launch Maven through MavenProcessInvoker.execute(), never call executeCommandLine with a manually obtained cli.","Handle CommandLineConfigurationException at build time so a null cli can never reach process spawning.","Add Objects.requireNonNull(cli) assertions in custom invoker subclasses.","Keep invoker request construction and execution in the same method to avoid passing unbuilt state."],"tags":["java","maven","illegal-argument","null-check"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}