diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-05-08 23:36:04 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-05-08 23:36:04 +0200 |
commit | 67c45347c0edff236eb3471a3318dfb8401bbab2 (patch) | |
tree | e9a7cc4376a0d7cd2c6bb6ca02cf4baa00405391 | |
parent | 8d0a77b19115d1db40cf04a38808d06a03283dd6 (diff) |
Do an explicit copy.
-rw-r--r-- | config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java | 5 | ||||
-rw-r--r-- | jrt/src/com/yahoo/jrt/DataValue.java | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java index 441ceb428af..4575368cc6a 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java @@ -15,6 +15,7 @@ import com.yahoo.vespa.config.util.ConfigUtils; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.Optional; import java.util.logging.Logger; @@ -104,7 +105,9 @@ public class JRTServerConfigRequestV3 implements JRTServerConfigRequest { if (buf.hasArray() && buf.remaining() == buf.array().length) { request.returnValues().add(new DataValue(buf.array())); } else { - request.returnValues().add(new DataValue(buf)); + byte [] dst = new byte[buf.remaining()]; + buf.get(dst); + request.returnValues().add(new DataValue(dst)); } } else { request.returnValues().add(new DataValue(new byte[0])); diff --git a/jrt/src/com/yahoo/jrt/DataValue.java b/jrt/src/com/yahoo/jrt/DataValue.java index 17a1f374a88..8739e4b3817 100644 --- a/jrt/src/com/yahoo/jrt/DataValue.java +++ b/jrt/src/com/yahoo/jrt/DataValue.java @@ -24,7 +24,7 @@ public class DataValue extends Value * * @param src buffer where the value is stored **/ - public DataValue(ByteBuffer src) { + DataValue(ByteBuffer src) { int size = src.getInt(); value = new byte[size]; src.get(value); |