Set ReplicationRequest.internalShardId to null
This commit sets ReplicationRequest.internalShardId to null when the stream indicates that no ShardId is present in the stream. Additionally, the use of StreamOutput#writeOptionalStreamable is changed to be explicit for clarity since the use of StreamInput#readOptionalStreamable is not possible due to the no-argument constructor on ShardId being private.
This commit is contained in:
parent
8ffb63a177
commit
756f7876a9
|
@ -155,6 +155,8 @@ public class ReplicationRequest<T extends ReplicationRequest> extends ActionRequ
|
|||
super.readFrom(in);
|
||||
if (in.readBoolean()) {
|
||||
internalShardId = ShardId.readShardId(in);
|
||||
} else {
|
||||
internalShardId = null;
|
||||
}
|
||||
consistencyLevel = WriteConsistencyLevel.fromId(in.readByte());
|
||||
timeout = TimeValue.readTimeValue(in);
|
||||
|
@ -164,7 +166,12 @@ public class ReplicationRequest<T extends ReplicationRequest> extends ActionRequ
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalStreamable(internalShardId);
|
||||
if (internalShardId != null) {
|
||||
out.writeBoolean(true);
|
||||
internalShardId.writeTo(out);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
out.writeByte(consistencyLevel.id());
|
||||
timeout.writeTo(out);
|
||||
out.writeString(index);
|
||||
|
|
Loading…
Reference in New Issue