humkum commented on code in PR #47:
URL:
https://github.com/apache/rocketmq-schema-registry/pull/47#discussion_r952661865
##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonDeserializer.java:
##########
@@ -35,31 +36,47 @@
public class JsonDeserializer<T> implements Deserializer<T> {
Logger log = LoggerFactory.getLogger(JsonDeserializer.class);
- private final SchemaRegistryClient registryClient;
- private final ObjectMapper objectMapper;
- private final Class<T> type;
+ private SchemaRegistryClient registryClient;
+ private final ObjectMapper objectMapper = JacksonMapper.INSTANCE;
+ private boolean skipSchemaRegistry;
+ private Class<T> type;
- public JsonDeserializer(SchemaRegistryClient registryClient, Class<T>
type) {
+ public JsonDeserializer() {
+ }
+
+ public JsonDeserializer(SchemaRegistryClient registryClient) {
this.registryClient = registryClient;
- objectMapper = JacksonMapper.INSTANCE;
- this.type = type;
}
@Override
public void configure(Map<String, Object> configs) {
-
+ JsonSerializerConfig serializerConfig = new
JsonSerializerConfig(configs);
+ this.skipSchemaRegistry = serializerConfig.skipSchemaRegistry();
+ this.type = (Class<T>) serializerConfig.deserializeTargetType();
}
@Override
public T deserialize(String subject, byte[] payload) {
- if (null == registryClient) {
- throw new SerializationException("please initialize the schema
registry client first");
- }
-
if (null == payload || payload.length == 0) {
return null;
}
+ if (null == type) {
+ throw new SerializationException("type cannot be null");
+ }
Review Comment:
when skipSchemaRegistry=true, there also need a specific type for
deserialize to a target type.
--
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]