Skip to content

Commit 9339fc8

Browse files
committed
Fix serialization bug in ShardFollowTask after cutting this class over to
extend from ImmutableFollowParameters. Prior to #38910 readVInt and writeVInt was used, #38910 accidentally changed ShardFollowTask to use readOptionalVInt / writeVOptionalVInt. This changes changes ShardFollowTask back to use vint.
1 parent c3f0df3 commit 9339fc8

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTask.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,24 @@ public class ShardFollowTask extends ImmutableFollowParameters implements XPackP
9393
}
9494

9595
public static ShardFollowTask readFrom(StreamInput in) throws IOException {
96-
return new ShardFollowTask(in.readString(), ShardId.readShardId(in), ShardId.readShardId(in), in);
97-
}
98-
99-
private ShardFollowTask(String remoteCluster, ShardId followShardId, ShardId leaderShardId, StreamInput in) throws IOException {
100-
super(in);
101-
this.remoteCluster = remoteCluster;
102-
this.followShardId = followShardId;
103-
this.leaderShardId = leaderShardId;
104-
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
96+
String remoteCluster = in.readString();
97+
ShardId followShardId = ShardId.readShardId(in);
98+
ShardId leaderShardId = ShardId.readShardId(in);
99+
// TODO: use ImmutableFollowParameters(StreamInput) constructor
100+
int maxReadRequestOperationCount = in.readVInt();
101+
ByteSizeValue maxReadRequestSize = new ByteSizeValue(in);
102+
int maxOutstandingReadRequests = in.readVInt();
103+
int maxWriteRequestOperationCount = in.readVInt();
104+
ByteSizeValue maxWriteRequestSize = new ByteSizeValue(in);
105+
int maxOutstandingWriteRequests = in.readVInt();
106+
int maxWriteBufferCount = in.readVInt();
107+
ByteSizeValue maxWriteBufferSize = new ByteSizeValue(in);
108+
TimeValue maxRetryDelay = in.readTimeValue();
109+
TimeValue readPollTimeout = in.readTimeValue();
110+
Map<String, String> headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
111+
return new ShardFollowTask(remoteCluster, followShardId, leaderShardId, maxReadRequestOperationCount,
112+
maxWriteRequestOperationCount, maxOutstandingReadRequests, maxOutstandingWriteRequests, maxReadRequestSize,
113+
maxWriteRequestSize, maxWriteBufferCount, maxWriteBufferSize, maxRetryDelay, readPollTimeout, headers);
105114
}
106115

107116
public String getRemoteCluster() {
@@ -130,7 +139,17 @@ public void writeTo(StreamOutput out) throws IOException {
130139
out.writeString(remoteCluster);
131140
followShardId.writeTo(out);
132141
leaderShardId.writeTo(out);
133-
super.writeTo(out);
142+
// TODO: use super.writeTo()
143+
out.writeVLong(getMaxReadRequestOperationCount());
144+
getMaxReadRequestSize().writeTo(out);
145+
out.writeVInt(getMaxOutstandingReadRequests());
146+
out.writeVLong(getMaxWriteRequestOperationCount());
147+
getMaxWriteRequestSize().writeTo(out);
148+
out.writeVInt(getMaxOutstandingWriteRequests());
149+
out.writeVInt(getMaxWriteBufferCount());
150+
getMaxWriteBufferSize().writeTo(out);
151+
out.writeTimeValue(getMaxRetryDelay());
152+
out.writeTimeValue(getReadPollTimeout());
134153
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
135154
}
136155

0 commit comments

Comments
 (0)