EdColeman commented on code in PR #3296:
URL: https://github.com/apache/accumulo/pull/3296#discussion_r1166123380


##########
test/src/main/java/org/apache/accumulo/test/metrics/TestStatsDSink.java:
##########
@@ -102,7 +103,8 @@ public TestStatsDSink() throws SocketException {
         DatagramPacket packet = new DatagramPacket(buf, len);
         try {
           sock.receive(packet);
-          received.add(new String(packet.getData()));
+          byte[] trimmedBuffer = Arrays.copyOf(packet.getData(), 
packet.getLength());
+          received.add(new String(trimmedBuffer));

Review Comment:
   Could this use the String constructor that takes start and length, something 
like 
   ```
             received.add(new String(packet.getData(),0, packet.getLength()));
   ```
   That would avoid an extra copy operation



-- 
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]

Reply via email to