apache/cassandra · warning

Ignoring codec because it collides with previously…

Error message

Ignoring codec {} because it collides with previously generated codec {}

What it means

CodecRegistry caches codecs it generates for (CQL type, Java type) keys. When registering a codec whose key matches an entry in that generated-codec cache, the new codec is warned about and ignored in favor of the cached, previously generated one.

Solutions

  1. Register all custom codecs immediately after cluster/session creation, before issuing any queries that cause codec generation
  2. Create a new session/registry if a cached generated codec must be overridden
  3. Use explicit codec arguments at bind/get sites instead of relying on registry resolution

Example fix

// before
session.execute(query);           // triggers generated codec caching
cluster.getConfiguration().getCodecRegistry().register(myCustomCodec);
// after
cluster.getConfiguration().getCodecRegistry().register(myCustomCodec);
session.execute(query);
Defensive patterns

Strategy: fallback

Validate before calling

// Register codecs before any session usage
function bootstrap(cluster) {
  cluster.getConfiguration().getCodecRegistry().registerAll(customCodecs);
  const session = cluster.connect(); // queries only after registration
  return session;
}

Try / catch

try {
  registry.register(myCodec);
} catch (IllegalStateException e) {
  // if registry API throws on collision in newer versions, create a fresh registry/session
  rebuildSessionWithFreshRegistry();
}

Prevention

When it happens

Trigger: register(newCodec) where cache.getIfPresent(new CacheKey(cqlType, javaType)) is non-null — i.e. the registry already auto-generated a codec for that exact pair (e.g. via codecFor lookups for lists/sets/maps/UDTs) before the custom codec was registered.

Common situations: Application performs queries (triggering codec generation) before finishing codec registration in startup code; lazy session initialization ordering issues.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/functions/types/CodecRegistry.java:482

                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());
        TypeCodec<?> existing = cache.getIfPresent(key);
        if (existing != null)
        {
            logger.warn(
            "Ignoring codec {} because it collides with previously generated codec {}",
            newCodec,
            existing);
            return this;
        }
        this.codecs.add(newCodec);
        return this;
    }

    /**
     * Register the given codecs with this registry.
     *
     * @param codecs The codecs to add to the registry.
     * @return this CodecRegistry (for method chaining).
     * @see #register(TypeCodec)
     */
    public CodecRegistry register(TypeCodec<?>... codecs)
    {

View on GitHub (pinned to 88fd0f6a0e)