Skip to content

Commit 3ee163b

Browse files
committed
Added a version check when reading and writing the fetch profiling results so that older nodes receive empty fetch results instead of failing on deserialization
Signed-off-by: Andre van de Ven <[email protected]>
1 parent bf5672e commit 3ee163b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/src/main/java/org/opensearch/search/profile/ProfileShardResult.java

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

3333
package org.opensearch.search.profile;
3434

35+
import org.opensearch.Version;
3536
import org.opensearch.common.annotation.PublicApi;
3637
import org.opensearch.core.common.io.stream.StreamInput;
3738
import org.opensearch.core.common.io.stream.StreamOutput;
@@ -83,7 +84,11 @@ public ProfileShardResult(StreamInput in) throws IOException {
8384
}
8485
this.queryProfileResults = Collections.unmodifiableList(queryProfileResults);
8586
this.aggProfileShardResult = new AggregationProfileShardResult(in);
86-
this.fetchProfileResult = new FetchProfileShardResult(in);
87+
if (in.getVersion().onOrAfter(Version.V_3_1_0)) {
88+
this.fetchProfileResult = new FetchProfileShardResult(in);
89+
} else {
90+
this.fetchProfileResult = new FetchProfileShardResult(Collections.emptyList());
91+
}
8792
this.networkTime = new NetworkTime(in);
8893
}
8994

@@ -94,7 +99,9 @@ public void writeTo(StreamOutput out) throws IOException {
9499
queryShardResult.writeTo(out);
95100
}
96101
aggProfileShardResult.writeTo(out);
97-
fetchProfileResult.writeTo(out);
102+
if (out.getVersion().onOrAfter(Version.V_3_1_0)) {
103+
fetchProfileResult.writeTo(out);
104+
}
98105
networkTime.writeTo(out);
99106
}
100107

0 commit comments

Comments
 (0)