apache/cassandra · error · ConfigurationException
ICompressor.serializedAs() of a compressor created by provid
Error message
ICompressor.serializedAs() of a compressor created by provider %s returned %s. It must return a non-anonymous built-in compressor class in package org.apache.cassandra.io.compress.
What it means
CompressorRegistry.getCompressor() resolves a compressor via a registered provider, then validates that ICompressor.serializedAs() returns a real class equal to the requested built-in compressor class. If it returns null, an empty/anonymous class name, a class outside org.apache.cassandra.io.compress, or a different class than requested, a ConfigurationException is thrown because the on-disk format would record a compressor name peers could never resolve.
Source
Thrown at src/java/org/apache/cassandra/io/compress/CompressorRegistry.java:183
if (provider == DEFAULT_COMPRESSION_PROVIDER)
throw t;
logger.warn("Failed to create compressor {}. Will attempt fallback to default if enabled. Message: {}",
compressorClass.getName(),
t.getMessage());
if (provider.isFailOnMissingProvider())
throw t;
compressor = DEFAULT_COMPRESSION_PROVIDER.createCompressor(compressorClass, compressionOptions);
}
// Validate the masquerade target for both the provider and the fallback path: whatever is
// returned must serialize as exactly the compressor class that was requested, otherwise the
// schema / on-disk format would record a name that cannot be resolved on peers and restarts.
Class<? extends ICompressor> serializedAs = compressor.serializedAs();
if (serializedAs == null || serializedAs.getSimpleName().isEmpty())
throw new ConfigurationException(String.format("ICompressor.serializedAs() of a compressor created by provider %s returned %s. " +
"It must return a non-anonymous built-in compressor class in package " +
"org.apache.cassandra.io.compress.",
provider.getClass(),
serializedAs));
if (serializedAs != compressorClass)
throw new ConfigurationException(String.format("The result of ICompressor.serializedAs(), %s, of a compressor object created " +
"by a compressor provider %s does not match the compressor class to get a compressor for. " +
"You need to override serializedAs() method of your custom compressor and return " +
"base compressor class it is the substitute for.",
serializedAs,
provider.getClass()));
return compressor;
}
/**
* Populates the registry with compression providers specified in the configuration.
* Should be called once during initialization to ensure providers are registered and available
* for use. If a provider fails to initialize and fallback is enabled, the default provider is used.View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Make the provider return a compressor whose serializedAs() is the exact built-in class requested (e.g. LZ4Compressor.class) in package org.apache.cassandra.io.compress
- Fix anonymous/wrapper compressors to delegate serializedAs() to the underlying built-in compressor
- Unregister/fix the offending provider and reconfigure the table to a built-in compressor class
- Add a startup self-check that calls getCompressor() for each configured compression class and fails fast
Example fix
// before
public Class<? extends ICompressor> serializedAs() { return this.getClass(); } // anonymous wrapper
// after
public Class<? extends ICompressor> serializedAs() { return LZ4Compressor.class; } // exact built-in target Defensive patterns
Strategy: validation
Validate before calling
// Java: pre-validate a provider's compressor before registering
Class<? extends ICompressor> sa = compressor.serializedAs();
if (sa == null || sa.getName().startsWith("org.apache.cassandra.io.compress.$")
|| !sa.getName().startsWith("org.apache.cassandra.io.compress."))
throw new ConfigurationException("Provider compressor serializes as non-builtin: " + sa); Type guard
static boolean isMasqueradeSafe(ICompressor c, Class<? extends ICompressor> requested) {
Class<? extends ICompressor> sa = c.serializedAs();
return sa != null && !sa.getSimpleName().isEmpty() && sa == requested;
} Try / catch
try { ICompressor c = CompressorRegistry.instance.getCompressor(LZ4Compressor.class, provider); }
catch (ConfigurationException e) { logger.error("Invalid compressor provider", e); useDefaultCompressor(); } Prevention
- Return built-in classes from serializedAs(), never anonymous/wrapper classes
- Add unit tests asserting serializedAs() equals the requested class
- Keep custom provider plugins in sync with registry expectations
- Fail fast at startup by resolving all configured compressors once
When it happens
Trigger: Registering a custom ICompressorProvider whose created compressor's serializedAs() returns null, an empty-named or anonymous class, a class not in the org.apache.cassandra.io.compress package, or a class differing from the one requested (masquerade failure).
Common situations: Custom compressor plugins implemented as anonymous or wrapper classes; providers returning repackaged compressors whose serializedAs points at the wrapper; typos in the registered class mapping; plugin version drift after upgrade.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- compressed_read_ahead_buffer_size must be at least 256KiB (s
- commitlog_disk_access_mode =
- SSTable format name in %s cannot be null
- SSTable format name for %s must be non-empty, lower-case let
- compressed_read_ahead_buffer_size_in_kb must be at least 256
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5c7b155a349861fd.
Report an issue: GitHub.