diff --git a/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index 58302428848..ac015258235 100644 --- a/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -426,14 +426,11 @@ public class SearchQueryIT extends ESIntegTestCase { 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)); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 61353d42ef1..235cf2ad24f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -48,6 +48,7 @@ import org.apache.lucene.util.TestUtil; 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; @@ -784,7 +785,17 @@ public abstract class ESTestCase extends LuceneTestCase { * 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)); + } } /**