[Schema Resolve] When the parameter of the listener method is an Object, JSON Schema cannot be used, and Byte Schema will be automatically used as a replacement. #773
Labels
status: waiting-for-feedback
We need additional information before we can continue
My Code
Below is my code. I want to use
Object
to receive the message and use JSON Schema. However, in practice, I cannot use JSON Schema; instead, Byte Schema is used, even though I explicitly specifiedschemaType = SchemaType.JSON
.Problem Analysis
After reading the source code, the issue might be here:
spring-pulsar/spring-pulsar/src/main/java/org/springframework/pulsar/config/MethodPulsarListenerEndpoint.java
Line 221 in af5c140
If
rawClass
is Object.class,isContainerType
will return true, leading to a ResolvableType with a null rawClass. This eventually causes an error in the SchemaResolver when parsing the Schema (essentially resulting inJSONSchema.of(null);
), which leads to the use of the defaultByteSchema
.My suggestion is: the
isContainerType
method should check whether rawClass is Object. If it is, return false directly; otherwise, continue checkingisAssignableFrom
.Expectations
@PulsarListener
or elsewhere, but SchemaResolver cannot resolve it correctly, an exception should be thrown instead of automatically using Byte Schema as a fallback.The text was updated successfully, but these errors were encountered: