You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2019/02/11 10:58:14 UTC

[tinkerpop] branch master updated: Avoid using ByteBuf#readCharSequence() for Netty 4.0 compat CTR

This is an automated email from the ASF dual-hosted git repository.

jorgebg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new 8061512  Avoid using ByteBuf#readCharSequence() for Netty 4.0 compat CTR
8061512 is described below

commit 806151291eb9fbb685720464977f2516a0fab23d
Author: Jorge Bay Gondra <jo...@gmail.com>
AuthorDate: Mon Feb 11 11:58:10 2019 +0100

    Avoid using ByteBuf#readCharSequence() for Netty 4.0 compat CTR
---
 .../tinkerpop/gremlin/driver/ser/binary/types/StringSerializer.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/StringSerializer.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/StringSerializer.java
index 93dbfe4..5267b5d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/StringSerializer.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/StringSerializer.java
@@ -34,8 +34,10 @@ public class StringSerializer extends SimpleTypeSerializer<String> {
 
     @Override
     protected String readValue(final ByteBuf buffer, final GraphBinaryReader context) {
-        final int length = buffer.readInt();
-        return buffer.readCharSequence(length, StandardCharsets.UTF_8).toString();
+        // Use Netty 4.0 API (avoid ByteBuf#readCharSequence() method) to maximize compatibility
+        final byte[] bytes = new byte[buffer.readInt()];
+        buffer.readBytes(bytes);
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 
     @Override