{"record":{"id":"4de8431f213c857b","repo":"apache/pulsar","slug":"this-method-is-not-supported","errorCode":null,"errorMessage":"This method is not supported","messagePattern":"This method is not supported","errorType":"exception","errorClass":"SchemaSerializationException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java","lineNumber":41,"sourceCode":"import org.apache.pulsar.client.api.Schema;\nimport org.apache.pulsar.client.api.SchemaSerializationException;\n\npublic abstract class AbstractSchema<T> implements Schema<T> {\n\n    /**\n     * Check if the message read able length length is a valid object for this schema.\n     *\n     * <p>The implementation can choose what its most efficient approach to validate the schema.\n     * If the implementation doesn't provide it, it will attempt to use {@link #decode(ByteBuf)}\n     * to see if this schema can decode this message or not as a validation mechanism to verify\n     * the bytes.\n     *\n     * @param byteBuf the messages to verify\n     * @return true if it is a valid message\n     * @throws SchemaSerializationException if it is not a valid message\n     */\n    void validate(ByteBuf byteBuf) {\n        throw new SchemaSerializationException(\"This method is not supported\");\n    };\n\n    /**\n     * Decode a byteBuf into an object using the schema definition and deserializer implementation\n     * <p>Do not modify reader/writer index of ByteBuf so, it can be reused to access correct data.\n     *\n     * @param byteBuf\n     *            the byte buffer to decode\n     * @return the deserialized object\n     */\n    public abstract T decode(ByteBuf byteBuf);\n    /**\n     * Decode a byteBuf into an object using a given version.\n     *\n     * @param byteBuf\n     *            the byte array to decode\n     * @param schemaVersion\n     *            the schema version to decode the object. null indicates using latest version.","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nSchema<MyType> s = new AbstractSchema<MyType>() { public MyType decode(byte[] b){...} };\nconsumer.validate(msg);\n// after\nSchema<MyType> s = new AbstractSchema<MyType>() {\n  public MyType decode(byte[] b){...}\n  public void validate(ByteBuf buf){ decode(buf.duplicate()); }\n};\nconsumer.validate(msg);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean supportsValidation(Schema<?> s) {\n  try { s.getClass().getDeclaredMethod(\"validate\", io.netty.buffer.ByteBuf.class); return true; }\n  catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try { schema.validate(buf); } catch (SchemaSerializationException e) { /* schema does not support validation; skip or decode manually */ }","preventionTips":["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."],"tags":["schema","validation","not-implemented","serialization"],"backgroundTag":"method-not-implemented","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}