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 <nik9000@gmail.com>

Closes #50827
This commit is contained in:
Christoph Büscher 2020-01-13 10:10:15 +01:00 committed by GitHub
parent 985c95dcca
commit c31a21c3d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -252,7 +252,8 @@ public abstract class Rounding implements Writeable {
}
TimeUnitRounding(StreamInput in) throws IOException {
this(DateTimeUnit.resolve(in.readByte()), in.readZoneId());
this(DateTimeUnit.resolve(in.readByte()),
in.getVersion().onOrAfter(Version.V_7_0_0) ? in.readZoneId() : DateUtils.of(in.readString()));
}
@Override
@ -467,7 +468,8 @@ public abstract class Rounding implements Writeable {
}
TimeIntervalRounding(StreamInput in) throws IOException {
this(in.readVLong(), in.readZoneId());
this(in.readVLong(),
in.getVersion().onOrAfter(Version.V_7_0_0) ? in.readZoneId() : DateUtils.of(in.readString()));
}
@Override

View File

@ -120,7 +120,6 @@ public class InternalAggregationsTests extends ESTestCase {
return new InternalAggregations(aggsList, topLevelPipelineAggs);
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50827")
public void testSerialization() throws Exception {
InternalAggregations aggregations = createTestInstance();
writeToAndReadFrom(aggregations, 0);