JSONSchema should works with generic (parameterized type) POJO/DTO.
See original GitHub issueExpected 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)
(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.
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
private Object payload;
and respective getter/setter instead of
private T payload;
System configuration
Pulsar version: 2.2.0 (but seems to be also affected on latest master branch)
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (6 by maintainers)
Top GitHub Comments
@vamsi360 ,
I cloned your fork and built it to version 1.8.3-ppe-9.10. I still get the errror.
We too have been hit by this issue trying to send generics