File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
server/src/main/java/org/elasticsearch/common/io/stream Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -386,12 +386,7 @@ public BigInteger readBigInteger() throws IOException {
386386 return new BigInteger (readString ());
387387 }
388388
389- @ Nullable
390- public Text readOptionalText () throws IOException {
391- int length = readInt ();
392- if (length == -1 ) {
393- return null ;
394- }
389+ private Text readText (int length ) throws IOException {
395390 byte [] bytes = new byte [length ];
396391 if (length > 0 ) {
397392 readBytes (bytes , 0 , length );
@@ -400,15 +395,19 @@ public Text readOptionalText() throws IOException {
400395 return new Text (encoded );
401396 }
402397
398+ @ Nullable
399+ public Text readOptionalText () throws IOException {
400+ int length = readInt ();
401+ if (length == -1 ) {
402+ return null ;
403+ }
404+ return readText (length );
405+ }
406+
403407 public Text readText () throws IOException {
404408 // use Text so we can cache the string if it's ever converted to it
405409 int length = readInt ();
406- byte [] bytes = new byte [length ];
407- if (length > 0 ) {
408- readBytes (bytes , 0 , length );
409- }
410- var encoded = new XContentString .EncodedBytes (bytes );
411- return new Text (encoded );
410+ return readText (length );
412411 }
413412
414413 @ Nullable
You can’t perform that action at this time.
0 commit comments