Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,11 @@ public void testDateRangeInQueryString() {
assertThat(e.toString(), containsString("unit [D] not supported for date math"));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37814")
// Issue #7880
public void testDateRangeInQueryStringWithTimeZone_7880() {
//the mapping needs to be provided upfront otherwise we are not sure how many failures we get back
//as with dynamic mappings some shards might be lacking behind and parse a different query
assertAcked(prepareCreate("test").addMapping(
"type", "past", "type=date"
));
assertAcked(prepareCreate("test").addMapping("type", "past", "type=date"));

ZoneId timeZone = randomZone();
String now = DateFormatter.forPattern("strict_date_optional_time").format(Instant.now().atZone(timeZone));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.Version;
import org.elasticsearch.bootstrap.BootstrapForTesting;
import org.elasticsearch.bootstrap.JavaVersion;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.metadata.IndexMetaData;
Expand Down Expand Up @@ -784,7 +785,17 @@ public static TimeZone randomTimeZone() {
* generate a random TimeZone from the ones available in java.time
*/
public static ZoneId randomZone() {
return ZoneId.of(randomFrom(JAVA_ZONE_IDS));
// work around a JDK bug, where java 8 cannot parse the timezone GMT0 back into a temporal accessor
// see https://bugs.openjdk.java.net/browse/JDK-8138664
if (JavaVersion.current().getVersion().get(0) == 8) {
ZoneId timeZone;
do {
timeZone = ZoneId.of(randomFrom(JAVA_ZONE_IDS));
} while (timeZone.equals(ZoneId.of("GMT0")));
return timeZone;
} else {
return ZoneId.of(randomFrom(JAVA_ZONE_IDS));
}
}

/**
Expand Down