apache/pulsar · error · SchemaSerializationException

Size of data received by DoubleSchema is not 8

Error message

Size of data received by DoubleSchema is not 8

What it means

DoubleSchema encodes doubles as exactly 8 bytes (big-endian IEEE 754). Its byte[] validate() throws SchemaSerializationException for any other length, guarding the decode path against truncated or oversized payloads.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/DoubleSchema.java:49

    private static final DoubleSchema INSTANCE;
    private static final SchemaInfo SCHEMA_INFO;

    static {
        SCHEMA_INFO = SchemaInfoImpl.builder()
            .name("Double")
            .type(SchemaType.DOUBLE)
            .schema(new byte[0]).build();
        INSTANCE = new DoubleSchema();
    }

    public static DoubleSchema of() {
        return INSTANCE;
    }

    @Override
    public void validate(byte[] message) {
        if (message.length != 8) {
            throw new SchemaSerializationException("Size of data received by DoubleSchema is not 8");
        }
    }

    @Override
    public void validate(ByteBuf message) {
        if (message.readableBytes() != 8) {
            throw new SchemaSerializationException("Size of data received by DoubleSchema is not 8");
        }
    }


    @Override
    public byte[] encode(Double message) {
        if (null == message) {
            return null;
        } else {
            long bits = Double.doubleToLongBits(message);
            return new byte[] {

View on GitHub (pinned to 820761864e)

Solutions

  1. Produce with Schema.DOUBLE so payloads are exactly 8 bytes
  2. Check the topic's registered schema matches DOUBLE
  3. Validate payload.length == 8 before manual decode

Example fix

// before
double d = doubleSchema.decode(payload); // throws if length != 8
// after
if (payload.length == 8) {
    double d = doubleSchema.decode(payload);
}
Defensive patterns

Strategy: validation

Validate before calling

if (message == null || message.length != 8) {
    throw new IllegalArgumentException("DOUBLE payload must be exactly 8 bytes");
}

Type guard

boolean isValidDoublePayload(byte[] msg) {
    return msg != null && msg.length == 8;
}

Try / catch

try {
    schema.validate(message);
} catch (SchemaSerializationException e) {
    log.warn("Malformed DOUBLE payload, length={}", message == null ? -1 : message.length);
}

Prevention

When it happens

Trigger: Calling Schema.DOUBLE().validate(byte[]) or decode with arrays of length != 8 — typically messages produced under a different schema (float, string, Avro-encoded) sent to a DOUBLE-schema topic.

Common situations: Producer/consumer schema mismatch; truncated messages from custom transports or bridges; hand-assembled byte payloads in tests.

Related errors


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