Skip to content

Commit ae8aa86

Browse files
committed
Update readOptionalText() to match readText()
1 parent 87afc97 commit ae8aa86

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,12 @@ public Text readOptionalText() throws IOException {
391391
if (length == -1) {
392392
return null;
393393
}
394-
var byteBuffs = BytesReference.toByteBuffers(readBytesReference(length));
395-
assert byteBuffs.length == 1;
396-
return new Text(byteBuffs[0]);
394+
byte[] bytes = new byte[length];
395+
if (length > 0) {
396+
readBytes(bytes, 0, length);
397+
}
398+
var byteBuff = ByteBuffer.wrap(bytes);
399+
return new Text(byteBuff);
397400
}
398401

399402
public Text readText() throws IOException {

0 commit comments

Comments
 (0)