|
@@ -805,7 +805,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|
|
* generate a random TimeZone from the ones available in java.util
|
|
|
*/
|
|
|
public static TimeZone randomTimeZone() {
|
|
|
- return TimeZone.getTimeZone(randomFrom(JAVA_TIMEZONE_IDS));
|
|
|
+ return TimeZone.getTimeZone(randomJodaAndJavaSupportedTimezone(JAVA_TIMEZONE_IDS));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -817,14 +817,25 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|
|
if (JavaVersion.current().getVersion().get(0) == 8) {
|
|
|
ZoneId timeZone;
|
|
|
do {
|
|
|
- timeZone = ZoneId.of(randomFrom(JAVA_ZONE_IDS));
|
|
|
+ timeZone = ZoneId.of(randomJodaAndJavaSupportedTimezone(JAVA_ZONE_IDS));
|
|
|
} while (timeZone.equals(ZoneId.of("GMT0")));
|
|
|
return timeZone;
|
|
|
} else {
|
|
|
- return ZoneId.of(randomFrom(JAVA_ZONE_IDS));
|
|
|
+ return ZoneId.of(randomJodaAndJavaSupportedTimezone(JAVA_ZONE_IDS));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * We need to exclude time zones not supported by joda (like SystemV* timezones)
|
|
|
+ * because they cannot be converted back to DateTimeZone which we currently
|
|
|
+ * still need to do internally e.g. in bwc serialization and in the extract() method
|
|
|
+ * //TODO remove once joda is not supported
|
|
|
+ */
|
|
|
+ private static String randomJodaAndJavaSupportedTimezone(List<String> zoneIds) {
|
|
|
+ return randomValueOtherThanMany(id -> JODA_TIMEZONE_IDS.contains(id) == false,
|
|
|
+ () -> randomFrom(zoneIds));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* helper to randomly perform on <code>consumer</code> with <code>value</code>
|
|
|
*/
|