apache/cassandra · error · ConfigurationException

Invalid value for system property: expected long value but g

Error message

Invalid value for system property: expected long value but got '%s'

What it means

Thrown by the LONG_CONVERTER used by CassandraRelevantProperties long getters when the property value cannot be decoded as a long via Long.decode, surfaced as a ConfigurationException with the bad value in the message.

Source

Thrown at src/java/org/apache/cassandra/config/CassandraRelevantProperties.java:1124

        {
            return Integer.decode(value);
        }
        catch (NumberFormatException e)
        {
            throw new ConfigurationException(String.format("Invalid value for system property: " +
                                                           "expected integer value but got '%s'", value));
        }
    };

    private static final PropertyConverter<Long> LONG_CONVERTER = value ->
    {
        try
        {
            return Long.decode(value);
        }
        catch (NumberFormatException e)
        {
            throw new ConfigurationException(String.format("Invalid value for system property: " +
                                                           "expected long value but got '%s'", value));
        }
    };

    private static final PropertyConverter<Long> SIZE_IN_BYTES_CONVERTER = value ->
    {
        try
        {
            return FBUtilities.parseHumanReadableBytes(value);
        }
        catch (ConfigurationException e)
        {
            throw new ConfigurationException(String.format("Invalid value for system property: " +
                                                           "expected size in bytes with unit but got '%s'\n%s", value, e));
        }
    };

    private static final PropertyConverter<Double> DOUBLE_CONVERTER = value ->

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set the property to a plain long literal (hex/octal allowed via Long.decode)
  2. Use getSizeInBytes or duration-aware getters for suffixed values
  3. Strip whitespace/separators from the value in your config tooling
  4. Catch ConfigurationException and log the offending property value

Example fix

// before
-Dcassandra.gc_warn_threshold_in_ms=1,000
// after
-Dcassandra.gc_warn_threshold_in_ms=1000
Defensive patterns

Strategy: validation

Validate before calling

String v = System.getProperty("cassandra.gc_warn_threshold_in_ms");
if (v != null) {
    try { Long.decode(v.trim()); }
    catch (NumberFormatException e) { throw new IllegalArgumentException("Not a long: " + v); }
}

Try / catch

try {
    long v = CassandraRelevantProperties.SOME_LONG.getLong();
} catch (ConfigurationException e) {
    long v = 1000L;
}

Prevention

When it happens

Trigger: Setting a long-typed system property to a non-numeric or overflowing string, e.g. -Dcassandra.some_long=8E or '1,000,000'.

Common situations: Locale-formatted numbers with separators, time/size suffixes placed on a raw long property, malformed values from templated config management.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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