{"record":{"id":"e8e4d39966633170","repo":"apache/maven","slug":"invalid-threads-core-multiplier-value-value","errorCode":null,"errorMessage":"Invalid threads core multiplier value: '{}'. Value must be positive.","messagePattern":"Invalid threads core multiplier value: '(.+?)'\\. Value must be positive\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java","lineNumber":1633,"sourceCode":"            final CommandLine commandLine, final String option, final Consumer<Boolean> setting) {\n        if (commandLine.hasOption(option)) {\n            setting.accept(true);\n        }\n    }\n\n    private void enableOnPresentOption(\n            final CommandLine commandLine, final char option, final Consumer<Boolean> setting) {\n        enableOnPresentOption(commandLine, String.valueOf(option), setting);\n    }\n\n    int calculateDegreeOfConcurrency(String threadConfiguration) {\n        try {\n            if (threadConfiguration.endsWith(\"C\")) {\n                String str = threadConfiguration.substring(0, threadConfiguration.length() - 1);\n                float coreMultiplier = Float.parseFloat(str);\n\n                if (coreMultiplier <= 0.0f) {\n                    throw new IllegalArgumentException(\"Invalid threads core multiplier value: '\" + threadConfiguration\n                            + \"'. Value must be positive.\");\n                }\n\n                int procs = Runtime.getRuntime().availableProcessors();\n                int threads = (int) (coreMultiplier * procs);\n                return threads == 0 ? 1 : threads;\n            } else {\n                int threads = Integer.parseInt(threadConfiguration);\n                if (threads <= 0) {\n                    throw new IllegalArgumentException(\n                            \"Invalid threads value: '\" + threadConfiguration + \"'. Value must be positive.\");\n                }\n                return threads;\n            }\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\"Invalid threads value: '\" + threadConfiguration\n                    + \"'. Supported are int and float values ending with C.\");\n        }","sourceCodeStart":1615,"sourceCodeEnd":1651,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L1615-L1651","documentation":"The -T / --threads option accepts either a plain integer (thread count) or a number ending in 'C' (a float multiplier of available processors, e.g. -T1.5C). MavenCli.calculateDegreeOfConcurrency() parses the multiplier with Float.parseFloat and requires it to be strictly greater than 0.0f; values like 0C, 0.0C, or -2C throw IllegalArgumentException before the build starts.","triggerScenarios":"mvn -T0C, mvn -T-0.5C, mvn -T0.0C. Dynamically built command lines such as -T${THREADS}C where THREADS is unset-but-defaulted to 0, empty, or a negative number from a CI variable.","commonSituations":"CI templates parameterizing thread count via environment variables that default to 0 or empty on some runners. Scripts computing a multiplier that can round down to zero on small/oversubscribed agents. Copy-pasting -T0C from notes where 0 was meant as 'auto' (which is not a thing here; the default -T1C-equivalent applies when the flag is omitted).","solutions":["Use a strictly positive multiplier: -T1C (one thread per core, the safe default), -T2C, or -T0.5C.","Fix the variable feeding the option: default THREADS=1 (not 0) in CI, e.g. mvn -T${THREADS:-1}C.","If you want a fixed number of worker threads, use the integer form -T4 instead of a multiplier.","Omit -T entirely for fully serial builds rather than passing -T0C."],"exampleFix":"# before\nmvn -T${THREADS}C package   # THREADS=0 -> IllegalArgumentException\n\n# after\nmvn -T${THREADS:-1}C package","handlingStrategy":"validation","validationCode":"// Validate a -T value before invoking mvn\nstatic int degreeOfConcurrency(String v) {\n    if (v.endsWith(\"C\") || v.endsWith(\"c\")) {\n        float m = Float.parseFloat(v.substring(0, v.length() - 1));\n        if (m <= 0f) throw new IllegalArgumentException(\"multiplier must be > 0: \" + v);\n        int t = (int) (m * Runtime.getRuntime().availableProcessors());\n        return Math.max(t, 1);\n    }\n    int n = Integer.parseInt(v);\n    if (n <= 0) throw new IllegalArgumentException(\"threads must be > 0: \" + v);\n    return n;\n}\n// launcher: degreeOfConcurrency(threadCfg); // throws before a half-started build","typeGuard":null,"tryCatchPattern":"try {\n    mavenCli.doMain(args, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid threads core multiplier value\")) {\n        // fall back to -T1C and re-invoke once\n    }\n    throw e;\n}","preventionTips":["Default CI thread variables to 1, never 0: -T${THREADS:-1}C.","Validate the -T value in your launcher with the same rule (int > 0, or float+C > 0) before spawning mvn.","Treat computed thread counts of 0 from nproc/cgroup quotas as bugs in the environment, and clamp to 1."],"tags":["maven","cli","threads","parallel-build","invalid-value"],"backgroundTag":"invalid-thread-count","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}