muse-dev[bot] commented on a change in pull request #5607:
URL: https://github.com/apache/skywalking/pull/5607#discussion_r497683144



##########
File path: 
apm-sniffer/apm-sdk-plugin/avro-plugin/src/main/java/org/apache/skywalking/apm/plugin/avro/SWServerRPCPlugin.java
##########
@@ -43,14 +43,27 @@ public SWServerRPCPlugin(String prefix) {
 
     @Override
     public void serverReceiveRequest(RPCContext context) {
-        Map meta = context.requestCallMeta();
+        Map<String, ByteBuffer> meta = context.requestCallMeta();
 
         ContextCarrier carrier = new ContextCarrier();
         CarrierItem items = carrier.items();
         while (items.hasNext()) {
             items = items.next();
-            ByteBuffer buffer = (ByteBuffer) meta.get(new 
Utf8(items.getHeadKey()));
-            items.setHeadValue(new String(buffer.array()));
+            ByteBuffer buffer = meta.get(items.getHeadKey());
+            String headValue;
+            if (buffer.hasArray()) {
+                headValue = new String(buffer.array());

Review comment:
       *ByteBufferBackingArray:*  ByteBuffer.array() shouldn't be called unless 
ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using 
ByteBuffer.wrap() or ByteBuffer.allocate().

##########
File path: 
apm-sniffer/apm-sdk-plugin/avro-plugin/src/main/java/org/apache/skywalking/apm/plugin/avro/SWServerRPCPlugin.java
##########
@@ -43,14 +43,27 @@ public SWServerRPCPlugin(String prefix) {
 
     @Override
     public void serverReceiveRequest(RPCContext context) {
-        Map meta = context.requestCallMeta();
+        Map<String, ByteBuffer> meta = context.requestCallMeta();
 
         ContextCarrier carrier = new ContextCarrier();
         CarrierItem items = carrier.items();
         while (items.hasNext()) {
             items = items.next();
-            ByteBuffer buffer = (ByteBuffer) meta.get(new 
Utf8(items.getHeadKey()));
-            items.setHeadValue(new String(buffer.array()));
+            ByteBuffer buffer = meta.get(items.getHeadKey());
+            String headValue;
+            if (buffer.hasArray()) {
+                headValue = new String(buffer.array());

Review comment:
       *DefaultCharset:*  Implicit use of the platform default charset, which 
can result in differing behaviour between JVM executions or incorrect behavior 
if the encoding of the data source doesn't match expectations.




----------------------------------------------------------------
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:
[email protected]


Reply via email to