You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/09/12 06:19:32 UTC

[GitHub] [pulsar] congbobo184 commented on a change in pull request #5123: Modify the schema decode method can decode ByteBuf

congbobo184 commented on a change in pull request #5123: Modify the schema decode method can decode ByteBuf
URL: https://github.com/apache/pulsar/pull/5123#discussion_r323571551
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/StringSchema.java
 ##########
 @@ -93,6 +102,22 @@ public String decode(byte[] bytes) {
         }
     }
 
+    public String decode(ByteBuf byteBuf) {
+        if (null == byteBuf) {
+            return null;
+        } else {
+            int size = byteBuf.readableBytes();
+            byte[] bytes = tmpBuffer.get();
+            if (size > bytes.length) {
+                bytes = new byte[size * 2];
+                tmpBuffer.set(bytes);
+            }
+            byteBuf.readBytes(bytes, 0, size);
+
+            return new String(bytes, 0, size, charset);
 
 Review comment:
   new String(bytes, 0, size, charset);  I looked at the source code and did a test, I did't find where be referenced. Can you give me some hints?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services