diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java index 58105908fdb3e..18f24e24d4759 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java @@ -98,13 +98,13 @@ public CommonStatsFlags(StreamInput in) throws IOException { includeUnloadedSegments = in.readBoolean(); includeAllShardIndexingPressureTrackers = in.readBoolean(); includeOnlyTopIndexingPressureMetrics = in.readBoolean(); + if (in.getVersion().onOrAfter(Version.V_2_16_0)) { + optimizeNodeIndicesStatsOnLevel = in.readOptionalBoolean(); + } if (in.getVersion().onOrAfter(Version.V_2_14_0)) { includeCaches = in.readEnumSet(CacheType.class); levels = in.readStringArray(); } - if (in.getVersion().onOrAfter(Version.V_2_16_0)) { - optimizeNodeIndicesStatsOnLevel = in.readOptionalBoolean(); - } } @Override @@ -125,13 +125,13 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(includeUnloadedSegments); out.writeBoolean(includeAllShardIndexingPressureTrackers); out.writeBoolean(includeOnlyTopIndexingPressureMetrics); + if (out.getVersion().onOrAfter(Version.V_2_16_0)) { + out.writeOptionalBoolean(optimizeNodeIndicesStatsOnLevel); + } if (out.getVersion().onOrAfter(Version.V_2_14_0)) { out.writeEnumSet(includeCaches); out.writeStringArrayNullable(levels); } - if (out.getVersion().onOrAfter(Version.V_2_16_0)) { - out.writeOptionalBoolean(optimizeNodeIndicesStatsOnLevel); - } } /**