apache/pulsar · error · UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

Schema.decode(String topic, ByteBuffer data, byte[] schemaId) is a default interface method that throws UnsupportedOperationException. Only schema implementations that support topic-aware decoding with an explicit schema id (e.g. MultiVersionSchema/protobuf-based schemas) override it. Calling it on a plain schema (AVRO, JSON, String, etc.) that inherited the default hits this stub.

Source

Thrown at pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java:143

        return decode(bytes);
    }

    /**
     * Decode a ByteBuffer into an object using a given version. <br/>
     *
     * @param data
     *            the ByteBuffer to decode
     * @return the deserialized object
     */
    default T decode(ByteBuffer data) {
        if (data == null) {
            return null;
        }
        return decode(getBytes(data));
    }

    default T decode(String topic, ByteBuffer data, byte[] schemaId) {
        throw new UnsupportedOperationException("Not implemented");
    }

    default T decode(String topic, byte[] data, byte[] schemaId) {
        throw new UnsupportedOperationException("Not implemented");
    }

    /**
     * Decode a ByteBuffer into an object using a given version. <br/>
     *
     * @param data
     *            the ByteBuffer to decode
     * @param schemaVersion
     *            the schema version to decode the object. null indicates using latest version.
     * @return the deserialized object
     */
    default T decode(ByteBuffer data, byte[] schemaVersion) {
        if (data == null) {
            return null;

View on GitHub (pinned to 820761864e)

Solutions

  1. Use the non-topic decode methods supported by all schemas: decode(byte[]), decode(ByteBuffer), or decode(byte[], byte[] schemaVersion).
  2. Implement the topic-aware decode method in your custom Schema class if you genuinely need per-topic semantics.
  3. Check schema.getSchemaInfo().getType() / supportSchemaVersioning capability before choosing the decode overload.

Example fix

// before
T value = schema.decode(topic, byteBuffer, schemaId); // UnsupportedOperationException on basic schemas
// after
T value = schema.decode(byteBuffer);
Defensive patterns

Strategy: try-catch

Validate before calling

static <T> boolean supportsTopicDecode(Schema<T> schema) {
    try {
        schema.getClass().getMethod("decode", String.class, ByteBuffer.class, byte[].class);
        return true;
    } catch (NoSuchMethodException e) { return false; }
}

Try / catch

try {
    value = schema.decode(topic, buffer, schemaId);
} catch (UnsupportedOperationException e) {
    value = schema.decode(buffer); // fall back to the universally-supported overload
}

Prevention

When it happens

Trigger: Invoking schema.decode(topic, byteBuffer, schemaId) on a schema instance whose class does not override the topic-aware overload — e.g. Schema.STRING or a SchemaInfo-built schema without reader-schema support.

Common situations: Generic framework code that always passes a topic and schemaId regardless of the schema type; custom Schema implementations that added the new method signature but never implemented it; code paths written against a richer schema type then reused with a basic one.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/b961e83f120dcfc6. Report an issue: GitHub.