You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/16 14:55:04 UTC

[GitHub] [rocketmq-schema-registry] humkum opened a new pull request, #41: support JSON serde

humkum opened a new pull request, #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41

   close #29 


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] humkum commented on pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
humkum commented on PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#issuecomment-1217545672

   > We still need compatibility validation for JSON type. Would you like to complete it with another pr? @humkum
   
   Yes,I just temporarily provide a usable version, I also considered there should be compatibility validation. I'll complete that.


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] MatrixHB commented on pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
MatrixHB commented on PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#issuecomment-1217541847

   We still need compatibility validation for JSON type. Would you like to complete it with another pr? @humkum 


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] MatrixHB commented on a diff in pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
MatrixHB commented on code in PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#discussion_r947509322


##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonDeserializer.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;

Review Comment:
   I suggest move JacksonMapper into `org.apache.rocketmq.schema.registry.client.serde.json` package



##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonDeserializer.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;
+import org.apache.rocketmq.schema.registry.client.serde.Deserializer;
+import org.apache.rocketmq.schema.registry.common.constant.SchemaConstants;
+import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+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;
+
+    public JsonDeserializer(SchemaRegistryClient registryClient, Class<T> type) {
+        this.registryClient = registryClient;
+        objectMapper = JacksonMapper.INSTANCE;
+        this.type = type;
+    }
+
+    @Override
+    public void configure(Map<String, Object> configs) {
+
+    }
+
+    @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;
+        }
+
+        try {
+            GetSchemaResponse response = registryClient.getSchemaBySubject(subject);
+            ByteBuffer buffer = ByteBuffer.wrap(payload);
+
+            long schemaRecordId = buffer.getLong();

Review Comment:
   schemaRecordId seems useless in the method, because schema is already obtained by subject. 
   
   Is there any plan to add the consistency check between recordID and the obtained schema, or add method to deserialize totally by payload like `T deserialize(byte[] payload)` ?



##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonSerializer.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;
+import org.apache.rocketmq.schema.registry.client.serde.Serializer;
+import org.apache.rocketmq.schema.registry.common.constant.SchemaConstants;
+import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public class JsonSerializer<T> implements Serializer<T> {
+    private final SchemaRegistryClient registryClient;
+    private final ObjectMapper objectMapper;
+    private final EncoderFactory encoderFactory = EncoderFactory.get();
+
+    public JsonSerializer(SchemaRegistryClient registryClient) {
+        this.objectMapper = JacksonMapper.INSTANCE;
+        this.registryClient = registryClient;
+    }
+
+    @Override
+    public void configure(Map<String, Object> configs) {
+
+    }
+
+    @Override
+    public byte[] serialize(String subject, T originMessage) {
+        if (null == originMessage) {
+            return null;
+        }
+
+        if (null == registryClient) {
+            throw new SerializationException("please initialize the schema registry client first");
+        }
+
+        try {
+            GetSchemaResponse response = registryClient.getSchemaBySubject(subject);
+            long schemaRecordId = response.getRecordId();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            ByteBuffer buffer = ByteBuffer.allocate(SchemaConstants.SCHEMA_RECORD_ID_LENGTH);
+            out.write(buffer.putLong(schemaRecordId).array());
+            out.write(objectMapper.writeValueAsBytes(originMessage));
+
+            byte[] bytes = out.toByteArray();
+            out.close();

Review Comment:
   @humkum 
   ```
   try {
       out.wrote(...);
   } finally {
       out.close();
   }
   ```
   may be better.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] humkum commented on a diff in pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
humkum commented on code in PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#discussion_r951191055


##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonSerializer.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;
+import org.apache.rocketmq.schema.registry.client.serde.Serializer;
+import org.apache.rocketmq.schema.registry.common.constant.SchemaConstants;
+import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public class JsonSerializer<T> implements Serializer<T> {
+    private final SchemaRegistryClient registryClient;
+    private final ObjectMapper objectMapper;
+    private final EncoderFactory encoderFactory = EncoderFactory.get();
+
+    public JsonSerializer(SchemaRegistryClient registryClient) {
+        this.objectMapper = JacksonMapper.INSTANCE;
+        this.registryClient = registryClient;
+    }
+
+    @Override
+    public void configure(Map<String, Object> configs) {
+
+    }
+
+    @Override
+    public byte[] serialize(String subject, T originMessage) {
+        if (null == originMessage) {
+            return null;
+        }
+
+        if (null == registryClient) {
+            throw new SerializationException("please initialize the schema registry client first");
+        }
+
+        try {
+            GetSchemaResponse response = registryClient.getSchemaBySubject(subject);
+            long schemaRecordId = response.getRecordId();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            ByteBuffer buffer = ByteBuffer.allocate(SchemaConstants.SCHEMA_RECORD_ID_LENGTH);
+            out.write(buffer.putLong(schemaRecordId).array());
+            out.write(objectMapper.writeValueAsBytes(originMessage));
+
+            byte[] bytes = out.toByteArray();
+            out.close();

Review Comment:
   I have fix this, please check this again.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] codecov-commenter commented on pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#issuecomment-1217470570

   # [Codecov](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#41](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (81f889e) into [main](https://codecov.io/gh/apache/rocketmq-schema-registry/commit/b0888c3fd0b75d4cca49c30992be890dd436733c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b0888c3) will **decrease** coverage by `0.66%`.
   > The diff coverage is `1.69%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##              main     #41      +/-   ##
   ==========================================
   - Coverage     9.57%   8.90%   -0.67%     
     Complexity      25      25              
   ==========================================
     Files           37      40       +3     
     Lines          773     831      +58     
     Branches        40      42       +2     
   ==========================================
     Hits            74      74              
   - Misses         693     751      +58     
     Partials         6       6              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...a/registry/client/serde/json/JsonDeserializer.java](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9zY2hlbWEvcmVnaXN0cnkvY2xpZW50L3NlcmRlL2pzb24vSnNvbkRlc2VyaWFsaXplci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...q/schema/registry/client/serde/json/JsonSerde.java](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9zY2hlbWEvcmVnaXN0cnkvY2xpZW50L3NlcmRlL2pzb24vSnNvblNlcmRlLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ema/registry/client/serde/json/JsonSerializer.java](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9zY2hlbWEvcmVnaXN0cnkvY2xpZW50L3NlcmRlL2pzb24vSnNvblNlcmlhbGl6ZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ema/registry/client/serde/avro/AvroSerializer.java](https://codecov.io/gh/apache/rocketmq-schema-registry/pull/41/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9zY2hlbWEvcmVnaXN0cnkvY2xpZW50L3NlcmRlL2F2cm8vQXZyb1NlcmlhbGl6ZXIuamF2YQ==) | `72.72% <100.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] ni-ze merged pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
ni-ze merged PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] ShannonDing commented on a diff in pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
ShannonDing commented on code in PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#discussion_r949791237


##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonSerializer.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;
+import org.apache.rocketmq.schema.registry.client.serde.Serializer;
+import org.apache.rocketmq.schema.registry.common.constant.SchemaConstants;
+import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public class JsonSerializer<T> implements Serializer<T> {
+    private final SchemaRegistryClient registryClient;
+    private final ObjectMapper objectMapper;
+    private final EncoderFactory encoderFactory = EncoderFactory.get();
+
+    public JsonSerializer(SchemaRegistryClient registryClient) {
+        this.objectMapper = JacksonMapper.INSTANCE;
+        this.registryClient = registryClient;
+    }
+
+    @Override
+    public void configure(Map<String, Object> configs) {
+
+    }
+
+    @Override
+    public byte[] serialize(String subject, T originMessage) {
+        if (null == originMessage) {
+            return null;
+        }
+
+        if (null == registryClient) {
+            throw new SerializationException("please initialize the schema registry client first");
+        }
+
+        try {
+            GetSchemaResponse response = registryClient.getSchemaBySubject(subject);
+            long schemaRecordId = response.getRecordId();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            ByteBuffer buffer = ByteBuffer.allocate(SchemaConstants.SCHEMA_RECORD_ID_LENGTH);
+            out.write(buffer.putLong(schemaRecordId).array());
+            out.write(objectMapper.writeValueAsBytes(originMessage));
+
+            byte[] bytes = out.toByteArray();
+            out.close();

Review Comment:
   make sure to close ByteArrayOutputStream. maybe let out.close() in finally.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-schema-registry] ShannonDing commented on a diff in pull request #41: support JSON serde

Posted by GitBox <gi...@apache.org>.
ShannonDing commented on code in PR #41:
URL: https://github.com/apache/rocketmq-schema-registry/pull/41#discussion_r949789635


##########
client/src/main/java/org/apache/rocketmq/schema/registry/client/serde/json/JsonDeserializer.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.schema.registry.client.serde.json;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.rocketmq.schema.registry.client.SchemaRegistryClient;
+import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException;
+import org.apache.rocketmq.schema.registry.client.exceptions.SerializationException;
+import org.apache.rocketmq.schema.registry.client.rest.JacksonMapper;
+import org.apache.rocketmq.schema.registry.client.serde.Deserializer;
+import org.apache.rocketmq.schema.registry.common.constant.SchemaConstants;
+import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+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;
+
+    public JsonDeserializer(SchemaRegistryClient registryClient, Class<T> type) {
+        this.registryClient = registryClient;
+        objectMapper = JacksonMapper.INSTANCE;
+        this.type = type;
+    }
+
+    @Override
+    public void configure(Map<String, Object> configs) {
+
+    }
+
+    @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) {

Review Comment:
   how about StringUtil?



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org