Skip to content

Commit

Permalink
Fix time zone issue in Rounding serialization
Browse files Browse the repository at this point in the history
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 elastic#50609.
Its at least necessary for some tests, e.g. the cause of elastic#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.
  • Loading branch information
Christoph Büscher committed Jan 10, 2020
1 parent 75cb4e0 commit 79992c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/common/Rounding.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static class TimeUnitRounding extends Rounding {
}

TimeUnitRounding(StreamInput in) throws IOException {
this(DateTimeUnit.resolve(in.readByte()), in.readZoneId());
this(DateTimeUnit.resolve(in.readByte()), DateUtils.of(in.readString()));
}

@Override
Expand Down Expand Up @@ -467,7 +467,7 @@ static class TimeIntervalRounding extends Rounding {
}

TimeIntervalRounding(StreamInput in) throws IOException {
this(in.readVLong(), in.readZoneId());
this(in.readVLong(), DateUtils.of(in.readString()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public static InternalAggregations createTestInstance() throws Exception {
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);
Expand Down

0 comments on commit 79992c4

Please sign in to comment.