Skip to content

Commit 47c124b

Browse files
committed
add version guard
Signed-off-by: xuxiong1 <[email protected]>
1 parent 4a4fc5b commit 47c124b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
package org.opensearch.action.admin.indices.stats;
3434

35+
import org.opensearch.Version;
3536
import org.opensearch.cluster.routing.ShardRouting;
3637
import org.opensearch.common.Nullable;
3738
import org.opensearch.common.annotation.PublicApi;
@@ -91,7 +92,9 @@ public ShardStats(StreamInput in) throws IOException {
9192
isCustomDataPath = in.readBoolean();
9293
seqNoStats = in.readOptionalWriteable(SeqNoStats::new);
9394
retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new);
94-
pollingIngestStats = in.readOptionalWriteable(PollingIngestStats::new);
95+
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
96+
pollingIngestStats = in.readOptionalWriteable(PollingIngestStats::new);
97+
}
9598
}
9699

97100
public ShardStats(
@@ -162,7 +165,9 @@ public void writeTo(StreamOutput out) throws IOException {
162165
out.writeBoolean(isCustomDataPath);
163166
out.writeOptionalWriteable(seqNoStats);
164167
out.writeOptionalWriteable(retentionLeaseStats);
165-
out.writeOptionalWriteable(pollingIngestStats);
168+
if (out.getVersion().onOrAfter((Version.V_3_0_0))) {
169+
out.writeOptionalWriteable(pollingIngestStats);
170+
}
166171
}
167172

168173
@Override

server/src/main/java/org/opensearch/action/admin/indices/stats/TransportIndicesStatsAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ protected ShardStats shardOperation(IndicesStatsRequest request, ShardRouting sh
148148
seqNoStats = indexShard.seqNoStats();
149149
retentionLeaseStats = indexShard.getRetentionLeaseStats();
150150
pollingIngestStats = indexShard.pollingIngestStats();
151-
152151
} catch (final AlreadyClosedException e) {
153152
// shard is closed - no stats is fine
154153
commitStats = null;

0 commit comments

Comments
 (0)