alibaba/arthas · warning · IllegalArgumentException

{optionName} is invalid: {value}

Error message

{optionName} is invalid: {value}

What it means

Thrown as IllegalArgumentException by parseTimeMillis when Long.parseLong(text) throws NumberFormatException — i.e. the numeric body of the value is not a valid integer. The unit suffix was stripped correctly (or absent), but the remaining text is non-numeric. The original value is echoed.

Source

Thrown at core/src/main/java/com/taobao/arthas/core/command/klass100/ClassLoaderMetaspaceCommand.java:480

        long multiplier = 1;
        if (text.endsWith("ms")) {
            text = text.substring(0, text.length() - 2).trim();
        } else if (text.endsWith("s")) {
            text = text.substring(0, text.length() - 1).trim();
            multiplier = 1000;
        } else if (text.endsWith("m")) {
            text = text.substring(0, text.length() - 1).trim();
            multiplier = 60 * 1000;
        }

        try {
            long millis = Long.parseLong(text) * multiplier;
            if (millis <= 0) {
                throw new IllegalArgumentException(optionName + " must be greater than 0.");
            }
            return millis;
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(optionName + " is invalid: " + value);
        }
    }

    private void logMappingSummary(MappingSummary summary) {
        logger.debug("{} mapping summary, loadedClasses={}, candidateLoaders={}, emittedMappings={}, bootstrapClasses={}, arrayClasses={}, primitiveClasses={}, duplicateLoaderClasses={}",
                DIAG_LOG_PREFIX, summary.loadedClassCount, summary.candidateLoaderCount, summary.emittedMappingCount,
                summary.bootstrapClassCount, summary.arrayClassCount, summary.primitiveClassCount,
                summary.duplicateLoaderClassCount);
    }

    private void logRecordingSummary(RecordingData data, long recordingSize) {
        logger.debug("{} recording summary, fileSizeBytes={}, statsEvents={}, distinctStatsRows={}, mappingEvents={}, fallbackMappings={}, mappedLoaderIds={}, mappingEventsWithoutLoader={}, duplicateStatsRows={}",
                DIAG_LOG_PREFIX, recordingSize, data.statsEventCount, data.statsRows.size(), data.mappingEventCount,
                data.fallbackMappings.size(), data.mappingByLoaderId.size(), data.mappingEventWithoutLoaderCount,
                data.duplicateStatsRowCount);
        if (data.mappingEventWithoutLoaderCount > 0) {
            logger.debug("{} mapping events without RecordedClassLoader. These events can still be used as fallback candidates. samples={}",
                    DIAG_LOG_PREFIX, data.mappingEventsWithoutLoaderSamples);

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Use only supported suffixes ms, s, m with an integer body (e.g. 5s, 200ms, 3m).
  2. Avoid decimals and unsupported units like min/sec/h.
  3. Double-check the echoed value in the message to spot typos.

Example fix

// before
classloader --refresh-interval 1.5s

// after
classloader --refresh-interval 2s
Defensive patterns

Strategy: validation

Validate before calling

if (!value.matches("(?i)\\d+(ms|s|m)?")) {
    // reject before calling parseTimeMillis
}

Type guard

static boolean isValidMillisDuration(String s) { return s != null && s.matches("(?i)\\d+(ms|s|m)?"); }

Try / catch

try { long ms = parseTimeMillis(value, optionName); } catch (IllegalArgumentException e) { /* echo value back to the user with valid-unit guidance */ }

Prevention

When it happens

Trigger: Pass a time option value whose body is non-numeric after unit stripping: 'abc', '5x' (unknown unit falls through as literal), '1.5s' (decimal), '', or text with stray characters. Unsupported suffixes are NOT stripped, so '5x' leaves '5x' which fails parseLong.

Common situations: User uses an unsupported unit ('5min' -> body '5min'), decimals ('1.5s'), or non-numeric junk; mismatch between expected suffix vocabulary (ms/s/m) and what the user typed.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/17073c15b7affcdf. Report an issue: GitHub.