Replies: 16 comments
-
So we use Avro underneath to generate a schema for the class. Parameterized/generics in Java are currently not support for schema generation in Avro. Though there is discussion and a PR to add that: https://issues.apache.org/jira/browse/AVRO-2248 Though not sure if that is ever going to get merged in. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick response. I hope the Avro fix will be merged soon (and not much performance overhead). Until then I will apply the work-around java.lang.Object - sufficient so far :) |
Beta Was this translation helpful? Give feedback.
-
Hi, I worked on AVRO-2248 and we stabilised it and use it in production in our company. We will resume the discussion and make the required changes to get it merged to master. For now, if generic types are required, you can use the fork https://github.com/vamsi360/avro |
Beta Was this translation helpful? Give feedback.
-
I cloned your fork and built it to version 1.8.3-ppe-9.10.
|
Beta Was this translation helpful? Give feedback.
-
I am facing the same problem. It seems we are creating the build in a wrong way |
Beta Was this translation helpful? Give feedback.
-
Hi @rohts-patil @shan-96 |
Beta Was this translation helpful? Give feedback.
-
We are trying to write to Avro Files using version 1.8.3-ppe-9.10 We are writing a java object from memory to a specified file using
However, we still get the same exception as mentioned above which we got through maven released version of Avro (1.8) Our schema (POJO) looks like this:
We want to define cc: @rohts-patil |
Beta Was this translation helpful? Give feedback.
-
We too have been hit by this issue trying to send generics
|
Beta Was this translation helpful? Give feedback.
-
@gaoran10 @congbobo184 Which of you have time to take a look at this issue? |
Beta Was this translation helpful? Give feedback.
-
@frankjkelly Which pulsar client are you using? |
Beta Was this translation helpful? Give feedback.
-
@sijie I am using 2.6.1 Client with 2.6.1 Server When I use the code as follows
I get the error
but this code works fine
Thanks! |
Beta Was this translation helpful? Give feedback.
-
@frankjkelly I see. So it is related to extracting the schema information using the AVRO library. We will take a look and circle back. |
Beta Was this translation helpful? Give feedback.
-
@frankjkelly I think, because you use generic type T, so use can't provide the specific type. we can't generate avro schema according to the json schema information. |
Beta Was this translation helpful? Give feedback.
-
Yes - as per @jerrypeng comment above https://issues.apache.org/jira/browse/AVRO-2248 Though not sure if that is ever going to get merged in." So it appears it's up to the folks on the Avro side? |
Beta Was this translation helpful? Give feedback.
-
@frankjkelly Yeah, currently it is blocked by apache/avro#356. I would encourage people to leave a comment in the avro issue and pull request to see if AVRO community can accelerate the process on adopting that change. |
Beta Was this translation helpful? Give feedback.
-
Thank you - will do! |
Beta Was this translation helpful? Give feedback.
-
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 (ducquoc@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)
Beta Was this translation helpful? Give feedback.
All reactions