apache/cassandra · error · IllegalArgumentException

Output file name must not be null or empty.

Error message

Output file name must not be null or empty.

What it means

validateOutputFileName is a static guard applied by the file() and apply() entry points. It rejects null or whitespace-only output file names before any profiler work starts, because async-profiler needs a concrete target file for its output.

Source

Thrown at src/java/org/apache/cassandra/service/AsyncProfilerService.java:394

        {
            @Override
            public String apply(AsyncProfiler asyncProfiler) throws Throwable
            {
                return asyncProfiler.execute("status");
            }
        });
    }

    @Override
    public synchronized boolean isEnabled()
    {
        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

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Provide a non-empty file name such as 'cassandra-profiling-results.html'
  2. Trim and check the value in tooling before invoking the MBean
  3. Fall back to a default name when the configured value is blank

Example fix

// before
service.apply("start", cfg.get("profiler.output")); // null
// after
String out = cfg.getOrDefault("profiler.output", "async-profiler.html").trim();
if (!out.isEmpty()) service.apply("start", out);
Defensive patterns

Strategy: validation

Validate before calling

if (outputFile == null || outputFile.trim().isEmpty()) throw new IllegalArgumentException("output file name required");

Type guard

boolean isValidOutputName(String s) { return s != null && !s.trim().isEmpty(); }

Try / catch

try { svc.apply(cmd, file); } catch (IllegalArgumentException e) { if (e.getMessage().contains("must not be null or empty")) { svc.apply(cmd, "async-profiler.html"); } else throw e; }

Prevention

When it happens

Trigger: Calling apply(cmd, outputFile) or setting the output file via file(...) with null, "", or a blank/whitespace-only string (e.g. from an unset config value).

Common situations: Config keys for the profiler output file left unset; scripting that interpolates an empty variable into the file name; JMX clients sending empty strings.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/28865c919a2f3034. Report an issue: GitHub.