JSONSchema should works with generic (parameterized type) POJO/DTO. No exception at runtime, or at least update documentation/errorMessage how to work-around/bypass the issue.
Actual behavior
Exception when running producer/consumer with JSONSchema.of(clazz) (or Schema.JSON(clazz) ) wiith generic/parameterized class:
Exception in thread "main" java.lang.NoSuchFieldError: KEY_VALUE
at org.apache.pulsar.client.impl.schema.KeyValueSchema.<init>(KeyValueSchema.java:50)
at org.apache.pulsar.client.api.Schema.<clinit>(Schema.java:128)
Steps to reproduce
Create Producer or Consumer with client API, using JSONSchema.of(clazz) (or Schema.JSON(clazz) ) wiith generic/parameterized class.
Compiled OK, but when running the client producer/consumer it throws exception.
Original Issue: apache/pulsar#3115
Expected behavior
JSONSchema should works with generic (parameterized type) POJO/DTO. No exception at runtime, or at least update documentation/errorMessage how to work-around/bypass the issue.
Actual behavior
Exception when running producer/consumer with
JSONSchema.of(clazz)
(orSchema.JSON(clazz)
) wiith generic/parameterized class:Steps to reproduce
Create Producer or Consumer with client API, using
JSONSchema.of(clazz)
(orSchema.JSON(clazz)
) wiith generic/parameterized class. Compiled OK, but when running the client producer/consumer it throws exception.Example (https://github.com/ducquoc/pulsar/commit/a0649dc8): https://github.com/ducquoc/pulsar/blob/fix-client-schema_json-schema-generic-parameterized-type/pulsar-functions/java-examples/src/main/java/org/apache/pulsar/functions/api/examples/pojo/BrokerMessage.java
** Work-around: use
and respective getter/setter instead of
System configuration
Pulsar version: 2.2.0 (but seems to be also affected on latest master branch)