apache/flink · error · UnsupportedOperationException

SimpleVersionedSerializerWrapper is not meant to be used as

Error message

SimpleVersionedSerializerWrapper is not meant to be used as a general TypeSerializer for state.

What it means

Thrown unconditionally by SimpleVersionedSerializerTypeSerializerProxy.snapshotConfiguration(). The proxy intentionally does not implement TypeSerializerSnapshot because it is a bridge for internal operators that need both SimpleVersionedSerializer and TypeSerializer semantics, not a general-purpose state serializer. Calling snapshotConfiguration (which the state backend does when registering a serializer for keyed/operator state) is a misuse.

Source

Thrown at flink-core/src/main/java/org/apache/flink/core/io/SimpleVersionedSerializerTypeSerializerProxy.java:134

    }

    @Override
    public boolean equals(Object other) {
        return other instanceof SimpleVersionedSerializerTypeSerializerProxy
                && ((SimpleVersionedSerializerTypeSerializerProxy<?>) other)
                        .serializerSupplier
                        .get()
                        .equals(serializerSupplier.get());
    }

    @Override
    public int hashCode() {
        return serializerSupplier.get().hashCode();
    }

    @Override
    public TypeSerializerSnapshot<T> snapshotConfiguration() {
        throw new UnsupportedOperationException(
                "SimpleVersionedSerializerWrapper is not meant to be used as a general TypeSerializer for state.");
    }

    private SimpleVersionedSerializer<T> getSerializer() {
        if (cachedSerializer != null) {
            return cachedSerializer;
        }
        cachedSerializer = serializerSupplier.get();
        return cachedSerializer;
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Do not use SimpleVersionedSerializerTypeSerializerProxy as a state TypeSerializer; provide a proper TypeSerializer implementation with a TypeSerializerSnapshot.
  2. If you need versioned serialization in state, implement a TypeSerializerSnapshot manually or use a serializer framework that supports it.
  3. Reserve the proxy for internal operator plumbing where snapshot is never invoked.

Example fix

// before — proxy used as state serializer (will fail on snapshot)
TypeSerializer<MyType> ser = new SimpleVersionedSerializerTypeSerializerProxy<>(() -> mySimpleSerializer);
stateDesc.setSerializer(ser);

// after — use a proper TypeSerializer with snapshot support
TypeSerializer<MyType> ser = new MyTypeSerializer(); // implements snapshotConfiguration()
stateDesc.setSerializer(ser);
Defensive patterns

Strategy: validation

Validate before calling

// Do not call snapshotConfiguration() on a proxy.
// If you need state serializer snapshots, use a full TypeSerializer implementation.

Type guard

!(serializer instanceof SimpleVersionedSerializerTypeSerializerProxy)

Prevention

When it happens

Trigger: Registering a SimpleVersionedSerializerTypeSerializerProxy as the serializer for managed state (keyed or operator state); frameworks that call snapshotConfiguration() during checkpoint barrier processing or state registration.

Common situations: Accidentally wrapping a SimpleVersionedSerializer in the proxy and using it where a full TypeSerializer (with snapshot) is required; misconfigured state backend that receives a proxy instead of a proper TypeSerializer.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/d6d72bbc7810a009. Report an issue: GitHub.