apache/cassandra · error · ConfigurationException

ReversedType takes exactly one argument, " + types.size() +

Error message

ReversedType takes exactly one argument, " + types.size() + " given

What it means

ReversedType.getInstance(TypeParser) wraps a base type with reversed comparator order, e.g. ReversedType(Int32Type). It throws ConfigurationException when the parser supplies a number of type parameters other than exactly one, since ReversedType takes a single base type argument.

Source

Thrown at src/java/org/apache/cassandra/db/marshal/ReversedType.java:46

import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.serializers.MarshalException;
import org.apache.cassandra.serializers.TypeSerializer;
import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.utils.bytecomparable.ByteComparable;
import org.apache.cassandra.utils.bytecomparable.ByteSource;

public class ReversedType<T> extends AbstractType<T>
{
    // interning instances
    private static final Map<AbstractType<?>, ReversedType> instances = new ConcurrentHashMap<>();

    public final AbstractType<T> baseType;

    public static <T> ReversedType<T> getInstance(TypeParser parser)
    {
        List<AbstractType<?>> types = parser.getTypeParameters();
        if (types.size() != 1)
            throw new ConfigurationException("ReversedType takes exactly one argument, " + types.size() + " given");
        return getInstance((AbstractType<T>) types.get(0));
    }

    public static <T> ReversedType<T> getInstance(AbstractType<T> baseType)
    {
        ReversedType<T> t = instances.get(baseType);
        return null == t
             ? instances.computeIfAbsent(baseType, ReversedType::new)
             : t;
    }

    private ReversedType(AbstractType<T> baseType)
    {
        super(ComparisonType.CUSTOM, baseType.valueLengthIfFixed());
        this.baseType = baseType;
    }

    public boolean isEmptyValueMeaningless()

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Supply exactly one type parameter: ReversedType(org.apache.cassandra.db.marshal.Int32Type).
  2. Verify the type string parameter count before parsing; use the server-generated comparator string as a template.
  3. Catch ConfigurationException around TypeParser.parse() and report the malformed reversed type definition.

Example fix

// before
TypeParser.parse("ReversedType(Int32Type, UTF8Type)");
// after
TypeParser.parse("ReversedType(Int32Type)");
Defensive patterns

Strategy: validation

Validate before calling

List<AbstractType<?>> types = parser.getTypeParameters();
if (types.size() != 1)
    throw new ConfigurationException("ReversedType requires exactly 1 parameter, got " + types.size());

Try / catch

try {
    ReversedType<?> rt = ReversedType.getInstance(parser);
} catch (ConfigurationException e) {
    // report malformed reversed type definition
}

Prevention

When it happens

Trigger: Parsing a type string like 'org.apache.cassandra.db.marshal.ReversedType' with zero parameters or with two or more parameters (e.g. ReversedType(Int32Type,UTF8Type)) into ReversedType.getInstance.

Common situations: Hand-edited comparator strings in schema definitions or cassandra.yaml; accidental duplication of the inner type; tooling that concatenates type parameters incorrectly.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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