{"record":{"id":"a76ff065dbb2e31d","repo":"apache/pulsar","slug":"size-of-data-received-by-doubleschema-is-not-8","errorCode":null,"errorMessage":"Size of data received by DoubleSchema is not 8","messagePattern":"Size of data received by DoubleSchema is not 8","errorType":"exception","errorClass":"SchemaSerializationException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/DoubleSchema.java","lineNumber":49,"sourceCode":"    private static final DoubleSchema INSTANCE;\n    private static final SchemaInfo SCHEMA_INFO;\n\n    static {\n        SCHEMA_INFO = SchemaInfoImpl.builder()\n            .name(\"Double\")\n            .type(SchemaType.DOUBLE)\n            .schema(new byte[0]).build();\n        INSTANCE = new DoubleSchema();\n    }\n\n    public static DoubleSchema of() {\n        return INSTANCE;\n    }\n\n    @Override\n    public void validate(byte[] message) {\n        if (message.length != 8) {\n            throw new SchemaSerializationException(\"Size of data received by DoubleSchema is not 8\");\n        }\n    }\n\n    @Override\n    public void validate(ByteBuf message) {\n        if (message.readableBytes() != 8) {\n            throw new SchemaSerializationException(\"Size of data received by DoubleSchema is not 8\");\n        }\n    }\n\n\n    @Override\n    public byte[] encode(Double message) {\n        if (null == message) {\n            return null;\n        } else {\n            long bits = Double.doubleToLongBits(message);\n            return new byte[] {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/DoubleSchema.java#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"Producer/consumer schema mismatch; truncated messages from custom transports or bridges; hand-assembled byte payloads in tests.","solutions":["Produce with Schema.DOUBLE so payloads are exactly 8 bytes","Check the topic's registered schema matches DOUBLE","Validate payload.length == 8 before manual decode"],"exampleFix":"// before\ndouble d = doubleSchema.decode(payload); // throws if length != 8\n// after\nif (payload.length == 8) {\n    double d = doubleSchema.decode(payload);\n}","handlingStrategy":"validation","validationCode":"if (message == null || message.length != 8) {\n    throw new IllegalArgumentException(\"DOUBLE payload must be exactly 8 bytes\");\n}","typeGuard":"boolean isValidDoublePayload(byte[] msg) {\n    return msg != null && msg.length == 8;\n}","tryCatchPattern":"try {\n    schema.validate(message);\n} catch (SchemaSerializationException e) {\n    log.warn(\"Malformed DOUBLE payload, length={}\", message == null ? -1 : message.length);\n}","preventionTips":["Publish DOUBLE topics with Schema.DOUBLE","Watch for FLOAT(4-byte) vs DOUBLE(8-byte) schema drift from producers","Validate external bridge payloads before decoding"],"tags":["pulsar","schema","double","validation","serialization"],"backgroundTag":"schema-payload-size-mismatch","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"}