Don't convert possibly corrupted bytes to UTF-8
If the translog UUID is corrupted we should not convert it to UTF-8 since it might be invalid. Instead we should compare the UTF-8 byte representation directly.
This commit is contained in:
parent
21ffd931ec
commit
1a44afed05
|
@ -233,8 +233,9 @@ public abstract class TranslogReader implements Closeable, Comparable<TranslogRe
|
|||
BytesRef ref = new BytesRef(len);
|
||||
ref.length = len;
|
||||
headerStream.read(ref.bytes, ref.offset, ref.length);
|
||||
if (ref.utf8ToString().equals(translogUUID) == false) {
|
||||
throw new TranslogCorruptedException("expected shard UUID [" + translogUUID + "] but got: [" + ref.utf8ToString() + "] this translog file belongs to a different translog");
|
||||
BytesRef uuidBytes = new BytesRef(translogUUID);
|
||||
if (uuidBytes.bytesEquals(ref) == false) {
|
||||
throw new TranslogCorruptedException("expected shard UUID [" + uuidBytes + "] but got: [" + ref + "] this translog file belongs to a different translog");
|
||||
}
|
||||
return new ImmutableTranslogReader(channelReference.getGeneration(), channelReference, ref.length + CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC) + RamUsageEstimator.NUM_BYTES_INT, checkpoint.offset, checkpoint.numOps);
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue