aymkhalil opened a new issue, #20092: URL: https://github.com/apache/pulsar/issues/20092
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Version Pulsar client 2.10.3, 2.10.2, 2.10.1. Please note the behavior was correct with 2.8.3 and 2.10.0 and regressed starting with 2.10.1 ### Minimal reproduce step Run the below program to create a topic with a JSON schema that has an optional double field. **Please note the behavior is correct if the field is not optional** ``` public static void main(String[] args) throws PulsarClientException { final PulsarClient client = PulsarClient.builder() //.serviceUrl("pulsar://localhost:65093") .serviceUrl("pulsar://localhost:6650") .build(); RecordSchemaBuilder schemaBuilder = SchemaBuilder.record("myrecord"); schemaBuilder.field("xdouble").type(SchemaType.DOUBLE).optional(); SchemaInfo schemaInfo = schemaBuilder.build(SchemaType.JSON); GenericSchema<GenericRecord> schema = Schema.generic(schemaInfo); GenericRecordBuilder builder = schema.newRecordBuilder(); builder.set("xdouble", 1.0d); GenericRecord record = builder.build(); Producer<GenericRecord> producer = client.newProducer(schema) .topic("persistent://public/default/json-topic3") .create(); producer.send(record); Consumer<GenericRecord> consumer = client.newConsumer(Schema.AUTO_CONSUME()) .topic("persistent://public/default/json-topic3") .subscriptionName("my-subscription2") .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) .subscribe(); var message = consumer.receive(); var value = ((JsonNode)message.getValue().getNativeObject()).get("xdouble").numberValue(); assertTrue("expected double, got " + value.getClass() , value instanceof Double); //consumer.acknowledge(message); client.close(); } ``` ### What did you expect to see? The assertion should pass ### What did you see instead? ``` Exception in thread "main" java.lang.AssertionError: expected double, got class java.math.BigDecimal at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.assertTrue(Assert.java:42) at org.example.SimpleConsumer.main(SimpleConsumer.java:63) ``` ### Anything else? _No response_ ### Are you willing to submit a PR? - [X] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
