apache/cassandra · error · IllegalArgumentException
Command can not be null or blank string.
Error message
Command can not be null or blank string.
What it means
validateCommand (invoked by apply) rejects null or blank raw async-profiler command strings. The apply() path forwards the command text to the profiler agent, so an empty command would be meaningless and is rejected up front.
Source
Thrown at src/java/org/apache/cassandra/service/AsyncProfilerService.java:405
{
return instance != null && asyncProfiler != null;
}
public static String validateOutputFileName(String outputFile)
{
if (outputFile == null || outputFile.trim().isEmpty())
throw new IllegalArgumentException("Output file name must not be null or empty.");
if (!VALID_FILENAME_REGEX_PATTERN.matcher(outputFile).matches())
throw new IllegalArgumentException(format("Output file name must match pattern %s.", VALID_FILENAME_REGEX_PATTERN));
return outputFile;
}
public static String validateCommand(String command)
{
if (command == null || command.isBlank())
throw new IllegalArgumentException("Command can not be null or blank string.");
return command;
}
/**
* @param duration duration of profiling
* @return converted string representation of duration to seconds
*/
public static int parseDuration(String duration)
{
int durationSeconds = new DurationSpec.IntSecondsBound(duration).toSeconds();
if (durationSeconds > MAX_SAFE_PROFILING_DURATION)
throw new IllegalArgumentException(format("Max profiling duration is %s seconds. If you need longer profiling, use execute command instead.",
MAX_SAFE_PROFILING_DURATION));
return durationSeconds;
}
private static void maybeCreateProfilesLogDir()View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a real async-profiler command such as 'start', 'stop', or 'status'
- Check the string is not blank before invoking apply
- Restore a default command in tooling when none is configured
Example fix
// before service.apply(cmdTemplate, file); // cmdTemplate == "" // after String cmd = cmdTemplate == null || cmdTemplate.isBlank() ? "start" : cmdTemplate; service.apply(cmd, file);
Defensive patterns
Strategy: validation
Validate before calling
if (command == null || command.isBlank()) throw new IllegalArgumentException("async-profiler command required"); Type guard
boolean isValidCommand(String c) { return c != null && !c.isBlank(); } Try / catch
try { svc.apply(cmd, file); } catch (IllegalArgumentException e) { if (e.getMessage().contains("null or blank")) { svc.apply("start", file); } else throw e; } Prevention
- Default to 'start'/'stop'/'status' commands when templating fails
- Assert command non-blank in scripts before JMX calls
- Avoid building commands from optional config values without fallbacks
When it happens
Trigger: Calling apply(null, outputFile) or apply(" ", outputFile); building the command string from an empty config/template variable.
Common situations: Scripting where the command template failed to render; JMX clients sending whitespace; refactors that dropped the default 'start'/'stop' command.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Output file name must not be null or empty.
- Invalid null element in list
- null is not supported inside collections
- null is not supported inside vectors
- Element at index %d is null (expected type %s); given %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5c475a315b1c44f1.
Report an issue: GitHub.