apache/cassandra · warning
Ignoring codec because it collides with previously…
Error message
Ignoring codec {} because it collides with previously registered codec {} What it means
CodecRegistry refuses (with a warning, not an exception) to register a custom TypeCodec that accepts the same CQL type and Java type as one of the driver's built-in codecs; the new codec is ignored and the registry is returned unchanged. BUILT_IN_CODECS always win over user codecs.
Solutions
- Register a codec only for mappings not already built-in (check TypeCodec primitives/TypeCodec.enumIntCodec etc.)
- If custom behavior is needed for a built-in mapping, bypass CodecRegistry and pass the codec explicitly to statement setters/getters
- Remove the redundant registration call
Example fix
// before registry.register(TypeCodec.blob()); // collides with built-in // after // no registration needed; built-in codec is used automatically
Defensive patterns
Strategy: validation
Validate before calling
// Only register codecs for non-builtin mappings
function needsRegistration(codec) {
const builtin = TypeCodec.primitiveMappings();
return !builtin.some(b => b.accepts(codec.getCqlType()) && b.accepts(codec.getJavaType()));
}
if (needsRegistration(myCodec)) registry.register(myCodec); Prevention
- Check built-in codec coverage before writing a custom codec
- Keep codec registrations in one bootstrap module to spot duplicates
- Re-audit custom codecs after driver upgrades
When it happens
Trigger: Calling codecRegistry.register(newCodec) where newCodec.getCqlType() and getJavaType() are both accepted by an existing built-in codec, e.g. registering a custom codec for (int <-> Integer).
Common situations: Users re-registering a codec for a primitive mapping that the Java driver already handles; copy-pasted codec tutorials for types already supported; driver-version upgrades that made a previously custom mapping built-in.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Codec not found for requested operation
- Ignoring codec because it collides with previously…
- Cannot parse 32-bits int value from
- Cannot parse 64-bits double value from
- Cannot parse 64-bits long value from
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/231946d229be4bdb.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/functions/types/CodecRegistry.java:460
/**
* Register the given codec with this registry.
*
* <p>This method will log a warning and ignore the codec if it collides with a previously
* registered one. Note that this check is not done in a completely thread-safe manner; codecs
* should typically be registered at application startup, not in a highly concurrent context (if a
* race condition occurs, the worst possible outcome is that no warning gets logged, and the codec
* gets registered but will never actually be used).
*
* @param newCodec The codec to add to the registry.
* @return this CodecRegistry (for method chaining).
*/
public CodecRegistry register(TypeCodec<?> newCodec)
{
for (TypeCodec<?> oldCodec : BUILT_IN_CODECS)
{
if (oldCodec.accepts(newCodec.getCqlType()) && oldCodec.accepts(newCodec.getJavaType()))
{
logger.warn(
"Ignoring codec {} because it collides with previously registered codec {}",
newCodec,
oldCodec);
return this;
}
}
for (TypeCodec<?> oldCodec : codecs)
{
if (oldCodec.accepts(newCodec.getCqlType()) && oldCodec.accepts(newCodec.getJavaType()))
{
logger.warn(
"Ignoring codec {} because it collides with previously registered codec {}",
newCodec,
oldCodec);
return this;
}
}
CacheKey key = new CacheKey(newCodec.getCqlType(), newCodec.getJavaType());View on GitHub (pinned to 88fd0f6a0e)