Skip to content

Commit c31a21c

Browse files
author
Christoph Büscher
authored
Fix time zone issue in Rounding serialization (#50845)
When deserializing time zones in the Rounding classes we used to include a tiny normalization step via `DateUtils.of(in.readString())` that was lost in #50609. Its at least necessary for some tests, e.g. the cause of #50827 is that when sending the default time zone ZoneOffset.UTC on a stream pre 7.0 we convert it to a "UTC" string id via `DateUtils.zoneIdToDateTimeZone`. This gets then read back as a UTC ZoneRegion, which should behave the same but fails the equality tests in our serialization tests. Reverting to the previous behaviour with an additional normalization step on 7.x. Co-authored-by: Nik Everett <[email protected]> Closes #50827
1 parent 985c95d commit c31a21c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

server/src/main/java/org/elasticsearch/common/Rounding.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ static class TimeUnitRounding extends Rounding {
252252
}
253253

254254
TimeUnitRounding(StreamInput in) throws IOException {
255-
this(DateTimeUnit.resolve(in.readByte()), in.readZoneId());
255+
this(DateTimeUnit.resolve(in.readByte()),
256+
in.getVersion().onOrAfter(Version.V_7_0_0) ? in.readZoneId() : DateUtils.of(in.readString()));
256257
}
257258

258259
@Override
@@ -467,7 +468,8 @@ static class TimeIntervalRounding extends Rounding {
467468
}
468469

469470
TimeIntervalRounding(StreamInput in) throws IOException {
470-
this(in.readVLong(), in.readZoneId());
471+
this(in.readVLong(),
472+
in.getVersion().onOrAfter(Version.V_7_0_0) ? in.readZoneId() : DateUtils.of(in.readString()));
471473
}
472474

473475
@Override

server/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationsTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public static InternalAggregations createTestInstance() throws Exception {
120120
return new InternalAggregations(aggsList, topLevelPipelineAggs);
121121
}
122122

123-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50827")
124123
public void testSerialization() throws Exception {
125124
InternalAggregations aggregations = createTestInstance();
126125
writeToAndReadFrom(aggregations, 0);

0 commit comments

Comments
 (0)