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:
Jason Tedor 2015-11-18 14:46:34 -05:00
parent 8ffb63a177
commit 756f7876a9
1 changed files with 8 additions and 1 deletions

View File

@ -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);