From f1050966e6a93cbd5ab17c843fbba26cf8875760 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 14 Sep 2018 08:39:33 -0700 Subject: [PATCH] fix timezone serialization for joda bwc --- .../java/org/elasticsearch/common/io/stream/StreamOutput.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index c7d1633355e93..b00706b78aedb 100644 --- a/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -686,7 +686,8 @@ public final void writeMap(final Map map, final Writer keyWriter o.writeByte((byte) 13); final JodaCompatibleZonedDateTime zonedDateTime = (JodaCompatibleZonedDateTime) v; String zoneId = zonedDateTime.getZonedDateTime().getZone().getId(); - o.writeString(DateTimeZone.UTC.getID()); + // joda does not understand "Z" for utc, so we must special case + o.writeString(zoneId.equals("Z") ? DateTimeZone.UTC.getID() : zoneId); o.writeLong(zonedDateTime.toInstant().toEpochMilli()); }); WRITERS = Collections.unmodifiableMap(writers);