apache/pulsar · error · SchemaSerializationException
This method is not supported
Error message
This method is not supported
What it means
AbstractSchema's default validate(ByteBuf) implementation is a sentinel: base schema classes that do not support byte-level validation throw this SchemaSerializationException when validate() is invoked. It indicates the schema in use does not implement message validation.
Source
Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java:41
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.api.SchemaSerializationException;
public abstract class AbstractSchema<T> implements Schema<T> {
/**
* Check if the message read able length length is a valid object for this schema.
*
* <p>The implementation can choose what its most efficient approach to validate the schema.
* If the implementation doesn't provide it, it will attempt to use {@link #decode(ByteBuf)}
* to see if this schema can decode this message or not as a validation mechanism to verify
* the bytes.
*
* @param byteBuf the messages to verify
* @return true if it is a valid message
* @throws SchemaSerializationException if it is not a valid message
*/
void validate(ByteBuf byteBuf) {
throw new SchemaSerializationException("This method is not supported");
};
/**
* Decode a byteBuf into an object using the schema definition and deserializer implementation
* <p>Do not modify reader/writer index of ByteBuf so, it can be reused to access correct data.
*
* @param byteBuf
* the byte buffer to decode
* @return the deserialized object
*/
public abstract T decode(ByteBuf byteBuf);
/**
* Decode a byteBuf into an object using a given version.
*
* @param byteBuf
* the byte array to decode
* @param schemaVersion
* the schema version to decode the object. null indicates using latest version.View on GitHub (pinned to 820761864e)
Solutions
- Override validate(ByteBuf) in your custom schema to actually check the payload.
- Do not call validate() on schemas that declare no validation support; guard with a capability check.
- Use a concrete schema type (e.g. struct schemas) that implements validation if you need it.
Example fix
// before
Schema<MyType> s = new AbstractSchema<MyType>() { public MyType decode(byte[] b){...} };
consumer.validate(msg);
// after
Schema<MyType> s = new AbstractSchema<MyType>() {
public MyType decode(byte[] b){...}
public void validate(ByteBuf buf){ decode(buf.duplicate()); }
};
consumer.validate(msg); Defensive patterns
Strategy: type-guard
Type guard
boolean supportsValidation(Schema<?> s) {
try { s.getClass().getDeclaredMethod("validate", io.netty.buffer.ByteBuf.class); return true; }
catch (NoSuchMethodException e) { return false; }
} Try / catch
try { schema.validate(buf); } catch (SchemaSerializationException e) { /* schema does not support validation; skip or decode manually */ } Prevention
- Override validate() in custom AbstractSchema subclasses.
- Only call validate() on schemas known to support it (struct/key-value schemas).
- Add unit tests that exercise validate() for every custom schema.
When it happens
Trigger: Calling validate(ByteBuf) (directly or via Consumer/Producer paths that verify incoming messages) on a schema extending AbstractSchema without overriding validate, e.g. schemas built from generic decoders that never implement validation.
Common situations: Custom schema implementations that forget to override validate(); code paths that call validate() unconditionally on schemas known not to support it; enabling features like consumer-side schema validation with a barebones schema.
Related errors
- Not implemented for ${this.getClass}
- Size of data received by BooleanSchema is not 1
- Size of data received by ByteSchema is not 1
- Size of data received by DoubleSchema is not 8
- Can not enable for all producers but denies for replicators,
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/4de8431f213c857b.
Report an issue: GitHub.