diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java index 82c4ca87cdde3..cd779ccbd1572 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java @@ -386,12 +386,12 @@ public void testParentFilterResolvedCorrectly() throws Exception { .startObject("dates") .field("type", "object") .startObject("properties") - .startObject("day").field("type", "date").field("format", "dateOptionalTime").endObject() + .startObject("day").field("type", "date").field("format", "date_optional_time").endObject() .startObject("month") .field("type", "object") .startObject("properties") - .startObject("end").field("type", "date").field("format", "dateOptionalTime").endObject() - .startObject("start").field("type", "date").field("format", "dateOptionalTime").endObject() + .startObject("end").field("type", "date").field("format", "date_optional_time").endObject() + .startObject("start").field("type", "date").field("format", "date_optional_time").endObject() .startObject("label").field("type", "keyword").endObject() .endObject() .endObject() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/fields/SearchFieldsIT.java index b55f3846f3ac4..3cf762e461e6d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/fields/SearchFieldsIT.java @@ -608,7 +608,7 @@ public void testStoredFieldsWithoutSource() throws Exception { .field("long_field", 4L) .field("float_field", 5.0f) .field("double_field", 6.0d) - .field("date_field", DateFormatter.forPattern("dateOptionalTime").format(date)) + .field("date_field", DateFormatter.forPattern("date_optional_time").format(date)) .field("boolean_field", true) .field("binary_field", Base64.getEncoder().encodeToString("testing text".getBytes("UTF-8"))) .endObject()).get(); @@ -640,7 +640,7 @@ public void testStoredFieldsWithoutSource() throws Exception { assertThat(searchHit.getFields().get("long_field").getValue(), equalTo((Object) 4L)); assertThat(searchHit.getFields().get("float_field").getValue(), equalTo((Object) 5.0f)); assertThat(searchHit.getFields().get("double_field").getValue(), equalTo((Object) 6.0d)); - String dateTime = DateFormatter.forPattern("dateOptionalTime").format(date); + String dateTime = DateFormatter.forPattern("date_optional_time").format(date); assertThat(searchHit.getFields().get("date_field").getValue(), equalTo((Object) dateTime)); assertThat(searchHit.getFields().get("boolean_field").getValue(), equalTo((Object) Boolean.TRUE)); assertThat(searchHit.getFields().get("binary_field").getValue(), equalTo(new BytesArray("testing text" .getBytes("UTF8")))); @@ -818,7 +818,7 @@ public void testDocValueFields() throws Exception { .field("long_field", 4L) .field("float_field", 5.0f) .field("double_field", 6.0d) - .field("date_field", DateFormatter.forPattern("dateOptionalTime").format(date)) + .field("date_field", DateFormatter.forPattern("date_optional_time").format(date)) .field("boolean_field", true) .field("binary_field", new byte[] {42, 100}) .field("ip_field", "::1") @@ -855,7 +855,7 @@ public void testDocValueFields() throws Exception { assertThat(searchResponse.getHits().getAt(0).getFields().get("float_field").getValue(), equalTo((Object) 5.0)); assertThat(searchResponse.getHits().getAt(0).getFields().get("double_field").getValue(), equalTo((Object) 6.0d)); assertThat(searchResponse.getHits().getAt(0).getFields().get("date_field").getValue(), - equalTo(DateFormatter.forPattern("dateOptionalTime").format(date))); + equalTo(DateFormatter.forPattern("date_optional_time").format(date))); assertThat(searchResponse.getHits().getAt(0).getFields().get("boolean_field").getValue(), equalTo((Object) true)); assertThat(searchResponse.getHits().getAt(0).getFields().get("text_field").getValue(), equalTo("foo")); assertThat(searchResponse.getHits().getAt(0).getFields().get("keyword_field").getValue(), equalTo("foo")); @@ -880,7 +880,7 @@ public void testDocValueFields() throws Exception { assertThat(searchResponse.getHits().getAt(0).getFields().get("float_field").getValue(), equalTo((Object) 5.0)); assertThat(searchResponse.getHits().getAt(0).getFields().get("double_field").getValue(), equalTo((Object) 6.0d)); assertThat(searchResponse.getHits().getAt(0).getFields().get("date_field").getValue(), - equalTo(DateFormatter.forPattern("dateOptionalTime").format(date))); + equalTo(DateFormatter.forPattern("date_optional_time").format(date))); assertThat(searchResponse.getHits().getAt(0).getFields().get("boolean_field").getValue(), equalTo((Object) true)); assertThat(searchResponse.getHits().getAt(0).getFields().get("text_field").getValue(), equalTo("foo")); assertThat(searchResponse.getHits().getAt(0).getFields().get("keyword_field").getValue(), equalTo("foo")); diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java index 80d241dbd23a6..baead057e3e21 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java @@ -51,7 +51,7 @@ */ public final class UnassignedInfo implements ToXContentFragment, Writeable { - public static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("dateOptionalTime").withZone(ZoneOffset.UTC); + public static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("date_optional_time").withZone(ZoneOffset.UTC); public static final Setting INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING = Setting.positiveTimeSetting("index.unassigned.node_left.delayed_timeout", TimeValue.timeValueMinutes(1), Property.Dynamic, diff --git a/server/src/main/java/org/elasticsearch/common/joda/Joda.java b/server/src/main/java/org/elasticsearch/common/joda/Joda.java index 07e19ab835d27..f234e6197ea21 100644 --- a/server/src/main/java/org/elasticsearch/common/joda/Joda.java +++ b/server/src/main/java/org/elasticsearch/common/joda/Joda.java @@ -22,6 +22,8 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; +import org.elasticsearch.common.time.FormatNames; +import org.elasticsearch.common.util.LazyInitializable; import org.joda.time.Chronology; import org.joda.time.DateTime; import org.joda.time.DateTimeField; @@ -48,9 +50,14 @@ import java.util.Locale; import java.util.regex.Pattern; +@Deprecated public class Joda { - private static DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Joda.class); - + // Joda.forPattern could be used even before the logging is initialized. + // If LogManager.getLogger is called before logging config is loaded + // it results in errors sent to status logger and startup to fail. + // Hence a lazy initialization. + private static final LazyInitializable deprecationLogger + = new LazyInitializable(() -> DeprecationLogger.getLogger(FormatNames.class)); /** * Parses a joda based pattern, including some named ones (similar to the built in Joda ISO ones). */ @@ -62,6 +69,14 @@ public static JodaDateFormatter forPattern(String input) { throw new IllegalArgumentException("No date pattern provided"); } + FormatNames formatName = FormatNames.forName(input); + if (formatName != null && formatName.isCamelCase(input)) { + String msg = "Camel case format name {} is deprecated and will be removed in a future version. " + + "Use snake case name {} instead."; + getDeprecationLogger() + .deprecate("camelCaseDateFormat", msg, formatName.getCamelCaseName(), formatName.getSnakeCaseName()); + } + DateTimeFormatter formatter; if ("basicDate".equals(input) || "basic_date".equals(input)) { formatter = ISODateTimeFormat.basicDate(); @@ -267,15 +282,15 @@ public static JodaDateFormatter forPattern(String input) { private static void maybeLogJodaDeprecation(String input) { if (input.contains("CC")) { - deprecationLogger.deprecate("joda-century-of-era-format", + getDeprecationLogger().deprecate("joda-century-of-era-format", "Use of 'C' (century-of-era) is deprecated and will not be supported in the next major version of Elasticsearch."); } if (input.contains("YY")) { - deprecationLogger.deprecate("joda-year-of-era-format", "Use of 'Y' (year-of-era) will change to 'y' in the" + + getDeprecationLogger().deprecate("joda-year-of-era-format", "Use of 'Y' (year-of-era) will change to 'y' in the" + " next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); } if (input.contains("xx")) { - deprecationLogger.deprecate("joda-week-based-year-format", "Use of 'x' (week-based-year) will change" + + getDeprecationLogger().deprecate("joda-week-based-year-format", "Use of 'x' (week-based-year) will change" + " to 'Y' in the next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); } } @@ -373,11 +388,11 @@ public int parseInto(DateTimeParserBucket bucket, String text, int position) { long millis = new BigDecimal(text).longValue() * factor; // check for deprecations, but after it has parsed correctly so invalid values aren't counted as deprecated if (millis < 0) { - deprecationLogger.deprecate("epoch-negative", "Use of negative values" + + getDeprecationLogger().deprecate("epoch-negative", "Use of negative values" + " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); } if (scientificNotation.matcher(text).find()) { - deprecationLogger.deprecate("epoch-scientific-notation", "Use of scientific notation" + + getDeprecationLogger().deprecate("epoch-scientific-notation", "Use of scientific notation" + " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); } DateTime dt = new DateTime(millis, DateTimeZone.UTC); @@ -396,6 +411,10 @@ public int parseInto(DateTimeParserBucket bucket, String text, int position) { } } + private static DeprecationLogger getDeprecationLogger() { + return deprecationLogger.getOrCompute(); + } + public static class EpochTimePrinter implements DateTimePrinter { private boolean hasMilliSecondPrecision; diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 75bf85b07bdc0..203698065453a 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -21,6 +21,8 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.SuppressForbidden; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.util.LazyInitializable; import java.time.Instant; import java.time.LocalDate; @@ -52,6 +54,13 @@ import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; public class DateFormatters { + // DateFormatters is being used even before the logging is initialized. + // If LogManager.getLogger is called before logging config is loaded + // it results in errors sent to status logger and startup to fail. + // Hence a lazy initialization. + private static final LazyInitializable deprecationLogger + = new LazyInitializable(() -> DeprecationLogger.getLogger(FormatNames.class)); + public static final WeekFields WEEK_FIELDS_ROOT = WeekFields.of(Locale.ROOT); private static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON = new DateTimeFormatterBuilder() @@ -1635,166 +1644,174 @@ public class DateFormatters { throw new IllegalArgumentException("No date pattern provided"); } - if ("iso8601".equals(input)) { + FormatNames formatName = FormatNames.forName(input); + if (formatName != null && formatName.isCamelCase(input)) { + String msg = "Camel case format name {} is deprecated and will be removed in a future version. " + + "Use snake case name {} instead."; + deprecationLogger.getOrCompute() + .deprecate("camelCaseDateFormat", msg, formatName.getCamelCaseName(), formatName.getSnakeCaseName()); + } + + if (FormatNames.ISO8601.matches(input)) { return ISO_8601; - } else if ("basicDate".equals(input) || "basic_date".equals(input)) { + } else if (FormatNames.BASIC_DATE.matches(input)) { return BASIC_DATE; - } else if ("basicDateTime".equals(input) || "basic_date_time".equals(input)) { + } else if (FormatNames.BASIC_DATE_TIME.matches(input)) { return BASIC_DATE_TIME; - } else if ("basicDateTimeNoMillis".equals(input) || "basic_date_time_no_millis".equals(input)) { + } else if (FormatNames.BASIC_DATE_TIME_NO_MILLIS.matches(input)) { return BASIC_DATE_TIME_NO_MILLIS; - } else if ("basicOrdinalDate".equals(input) || "basic_ordinal_date".equals(input)) { + } else if (FormatNames.BASIC_ORDINAL_DATE.matches(input)) { return BASIC_ORDINAL_DATE; - } else if ("basicOrdinalDateTime".equals(input) || "basic_ordinal_date_time".equals(input)) { + } else if (FormatNames.BASIC_ORDINAL_DATE_TIME.matches(input)) { return BASIC_ORDINAL_DATE_TIME; - } else if ("basicOrdinalDateTimeNoMillis".equals(input) || "basic_ordinal_date_time_no_millis".equals(input)) { + } else if (FormatNames.BASIC_ORDINAL_DATE_TIME_NO_MILLIS.matches(input)) { return BASIC_ORDINAL_DATE_TIME_NO_MILLIS; - } else if ("basicTime".equals(input) || "basic_time".equals(input)) { + } else if (FormatNames.BASIC_TIME.matches(input)) { return BASIC_TIME; - } else if ("basicTimeNoMillis".equals(input) || "basic_time_no_millis".equals(input)) { + } else if (FormatNames.BASIC_TIME_NO_MILLIS.matches(input)) { return BASIC_TIME_NO_MILLIS; - } else if ("basicTTime".equals(input) || "basic_t_time".equals(input)) { + } else if (FormatNames.BASIC_T_TIME.matches(input)) { return BASIC_T_TIME; - } else if ("basicTTimeNoMillis".equals(input) || "basic_t_time_no_millis".equals(input)) { + } else if (FormatNames.BASIC_T_TIME_NO_MILLIS.matches(input)) { return BASIC_T_TIME_NO_MILLIS; - } else if ("basicWeekDate".equals(input) || "basic_week_date".equals(input)) { + } else if (FormatNames.BASIC_WEEK_DATE.matches(input)) { return BASIC_WEEK_DATE; - } else if ("basicWeekDateTime".equals(input) || "basic_week_date_time".equals(input)) { + } else if (FormatNames.BASIC_WEEK_DATE_TIME.matches(input)) { return BASIC_WEEK_DATE_TIME; - } else if ("basicWeekDateTimeNoMillis".equals(input) || "basic_week_date_time_no_millis".equals(input)) { + } else if (FormatNames.BASIC_WEEK_DATE_TIME_NO_MILLIS.matches(input)) { return BASIC_WEEK_DATE_TIME_NO_MILLIS; - } else if ("date".equals(input)) { + } else if (FormatNames.DATE.matches(input)) { return DATE; - } else if ("dateHour".equals(input) || "date_hour".equals(input)) { + } else if (FormatNames.DATE_HOUR.matches(input)) { return DATE_HOUR; - } else if ("dateHourMinute".equals(input) || "date_hour_minute".equals(input)) { + } else if (FormatNames.DATE_HOUR_MINUTE.matches(input)) { return DATE_HOUR_MINUTE; - } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { + } else if (FormatNames.DATE_HOUR_MINUTE_SECOND.matches(input)) { return DATE_HOUR_MINUTE_SECOND; - } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { + } else if (FormatNames.DATE_HOUR_MINUTE_SECOND_FRACTION.matches(input)) { return DATE_HOUR_MINUTE_SECOND_FRACTION; - } else if ("dateHourMinuteSecondMillis".equals(input) || "date_hour_minute_second_millis".equals(input)) { + } else if (FormatNames.DATE_HOUR_MINUTE_SECOND_MILLIS.matches(input)) { return DATE_HOUR_MINUTE_SECOND_MILLIS; - } else if ("dateOptionalTime".equals(input) || "date_optional_time".equals(input)) { + } else if (FormatNames.DATE_OPTIONAL_TIME.matches(input)) { return DATE_OPTIONAL_TIME; - } else if ("dateTime".equals(input) || "date_time".equals(input)) { + } else if (FormatNames.DATE_TIME.matches(input)) { return DATE_TIME; - } else if ("dateTimeNoMillis".equals(input) || "date_time_no_millis".equals(input)) { + } else if (FormatNames.DATE_TIME_NO_MILLIS.matches(input)) { return DATE_TIME_NO_MILLIS; - } else if ("hour".equals(input)) { + } else if (FormatNames.HOUR.matches(input)) { return HOUR; - } else if ("hourMinute".equals(input) || "hour_minute".equals(input)) { + } else if (FormatNames.HOUR_MINUTE.matches(input)) { return HOUR_MINUTE; - } else if ("hourMinuteSecond".equals(input) || "hour_minute_second".equals(input)) { + } else if (FormatNames.HOUR_MINUTE_SECOND.matches(input)) { return HOUR_MINUTE_SECOND; - } else if ("hourMinuteSecondFraction".equals(input) || "hour_minute_second_fraction".equals(input)) { + } else if (FormatNames.HOUR_MINUTE_SECOND_FRACTION.matches(input)) { return HOUR_MINUTE_SECOND_FRACTION; - } else if ("hourMinuteSecondMillis".equals(input) || "hour_minute_second_millis".equals(input)) { + } else if (FormatNames.HOUR_MINUTE_SECOND_MILLIS.matches(input)) { return HOUR_MINUTE_SECOND_MILLIS; - } else if ("ordinalDate".equals(input) || "ordinal_date".equals(input)) { + } else if (FormatNames.ORDINAL_DATE.matches(input)) { return ORDINAL_DATE; - } else if ("ordinalDateTime".equals(input) || "ordinal_date_time".equals(input)) { + } else if (FormatNames.ORDINAL_DATE_TIME.matches(input)) { return ORDINAL_DATE_TIME; - } else if ("ordinalDateTimeNoMillis".equals(input) || "ordinal_date_time_no_millis".equals(input)) { + } else if (FormatNames.ORDINAL_DATE_TIME_NO_MILLIS.matches(input)) { return ORDINAL_DATE_TIME_NO_MILLIS; - } else if ("time".equals(input)) { + } else if (FormatNames.TIME.matches(input)) { return TIME; - } else if ("timeNoMillis".equals(input) || "time_no_millis".equals(input)) { + } else if (FormatNames.TIME_NO_MILLIS.matches(input)) { return TIME_NO_MILLIS; - } else if ("tTime".equals(input) || "t_time".equals(input)) { + } else if (FormatNames.T_TIME.matches(input)) { return T_TIME; - } else if ("tTimeNoMillis".equals(input) || "t_time_no_millis".equals(input)) { + } else if (FormatNames.T_TIME_NO_MILLIS.matches(input)) { return T_TIME_NO_MILLIS; - } else if ("weekDate".equals(input) || "week_date".equals(input)) { + } else if (FormatNames.WEEK_DATE.matches(input)) { return WEEK_DATE; - } else if ("weekDateTime".equals(input) || "week_date_time".equals(input)) { + } else if (FormatNames.WEEK_DATE_TIME.matches(input)) { return WEEK_DATE_TIME; - } else if ("weekDateTimeNoMillis".equals(input) || "week_date_time_no_millis".equals(input)) { + } else if (FormatNames.WEEK_DATE_TIME_NO_MILLIS.matches(input)) { return WEEK_DATE_TIME_NO_MILLIS; - } else if ("weekyear".equals(input) || "week_year".equals(input)) { + } else if (FormatNames.WEEK_YEAR.matches(input)) { return WEEK_YEAR; - } else if ("weekyearWeek".equals(input) || "weekyear_week".equals(input)) { + } else if (FormatNames.WEEK_YEAR_WEEK.matches(input)) { return WEEKYEAR_WEEK; - } else if ("weekyearWeekDay".equals(input) || "weekyear_week_day".equals(input)) { + } else if (FormatNames.WEEKYEAR_WEEK_DAY.matches(input)) { return WEEKYEAR_WEEK_DAY; - } else if ("year".equals(input)) { + } else if (FormatNames.YEAR.matches(input)) { return YEAR; - } else if ("yearMonth".equals(input) || "year_month".equals(input)) { + } else if (FormatNames.YEAR_MONTH.matches(input)) { return YEAR_MONTH; - } else if ("yearMonthDay".equals(input) || "year_month_day".equals(input)) { + } else if (FormatNames.YEAR_MONTH_DAY.matches(input)) { return YEAR_MONTH_DAY; - } else if ("epoch_second".equals(input)) { + } else if (FormatNames.EPOCH_SECOND.matches(input)) { return EpochTime.SECONDS_FORMATTER; - } else if ("epoch_millis".equals(input)) { + } else if (FormatNames.EPOCH_MILLIS.matches(input)) { return EpochTime.MILLIS_FORMATTER; // strict date formats here, must be at least 4 digits for year and two for months and two for day - } else if ("strictBasicWeekDate".equals(input) || "strict_basic_week_date".equals(input)) { + } else if (FormatNames.STRICT_BASIC_WEEK_DATE.matches(input)) { return STRICT_BASIC_WEEK_DATE; - } else if ("strictBasicWeekDateTime".equals(input) || "strict_basic_week_date_time".equals(input)) { + } else if (FormatNames.STRICT_BASIC_WEEK_DATE_TIME.matches(input)) { return STRICT_BASIC_WEEK_DATE_TIME; - } else if ("strictBasicWeekDateTimeNoMillis".equals(input) || "strict_basic_week_date_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_BASIC_WEEK_DATE_TIME_NO_MILLIS.matches(input)) { return STRICT_BASIC_WEEK_DATE_TIME_NO_MILLIS; - } else if ("strictDate".equals(input) || "strict_date".equals(input)) { + } else if (FormatNames.STRICT_DATE.matches(input)) { return STRICT_DATE; - } else if ("strictDateHour".equals(input) || "strict_date_hour".equals(input)) { + } else if (FormatNames.STRICT_DATE_HOUR.matches(input)) { return STRICT_DATE_HOUR; - } else if ("strictDateHourMinute".equals(input) || "strict_date_hour_minute".equals(input)) { + } else if (FormatNames.STRICT_DATE_HOUR_MINUTE.matches(input)) { return STRICT_DATE_HOUR_MINUTE; - } else if ("strictDateHourMinuteSecond".equals(input) || "strict_date_hour_minute_second".equals(input)) { + } else if (FormatNames.STRICT_DATE_HOUR_MINUTE_SECOND.matches(input)) { return STRICT_DATE_HOUR_MINUTE_SECOND; - } else if ("strictDateHourMinuteSecondFraction".equals(input) || "strict_date_hour_minute_second_fraction".equals(input)) { + } else if (FormatNames.STRICT_DATE_HOUR_MINUTE_SECOND_FRACTION.matches(input)) { return STRICT_DATE_HOUR_MINUTE_SECOND_FRACTION; - } else if ("strictDateHourMinuteSecondMillis".equals(input) || "strict_date_hour_minute_second_millis".equals(input)) { + } else if (FormatNames.STRICT_DATE_HOUR_MINUTE_SECOND_MILLIS.matches(input)) { return STRICT_DATE_HOUR_MINUTE_SECOND_MILLIS; - } else if ("strictDateOptionalTime".equals(input) || "strict_date_optional_time".equals(input)) { + } else if (FormatNames.STRICT_DATE_OPTIONAL_TIME.matches(input)) { return STRICT_DATE_OPTIONAL_TIME; - } else if ("strictDateOptionalTimeNanos".equals(input) || "strict_date_optional_time_nanos".equals(input)) { + } else if (FormatNames.STRICT_DATE_OPTIONAL_TIME_NANOS.matches(input)) { return STRICT_DATE_OPTIONAL_TIME_NANOS; - } else if ("strictDateTime".equals(input) || "strict_date_time".equals(input)) { + } else if (FormatNames.STRICT_DATE_TIME.matches(input)) { return STRICT_DATE_TIME; - } else if ("strictDateTimeNoMillis".equals(input) || "strict_date_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_DATE_TIME_NO_MILLIS.matches(input)) { return STRICT_DATE_TIME_NO_MILLIS; - } else if ("strictHour".equals(input) || "strict_hour".equals(input)) { + } else if (FormatNames.STRICT_HOUR.matches(input)) { return STRICT_HOUR; - } else if ("strictHourMinute".equals(input) || "strict_hour_minute".equals(input)) { + } else if (FormatNames.STRICT_HOUR_MINUTE.matches(input)) { return STRICT_HOUR_MINUTE; - } else if ("strictHourMinuteSecond".equals(input) || "strict_hour_minute_second".equals(input)) { + } else if (FormatNames.STRICT_HOUR_MINUTE_SECOND.matches(input)) { return STRICT_HOUR_MINUTE_SECOND; - } else if ("strictHourMinuteSecondFraction".equals(input) || "strict_hour_minute_second_fraction".equals(input)) { + } else if (FormatNames.STRICT_HOUR_MINUTE_SECOND_FRACTION.matches(input)) { return STRICT_HOUR_MINUTE_SECOND_FRACTION; - } else if ("strictHourMinuteSecondMillis".equals(input) || "strict_hour_minute_second_millis".equals(input)) { + } else if (FormatNames.STRICT_HOUR_MINUTE_SECOND_MILLIS.matches(input)) { return STRICT_HOUR_MINUTE_SECOND_MILLIS; - } else if ("strictOrdinalDate".equals(input) || "strict_ordinal_date".equals(input)) { + } else if (FormatNames.STRICT_ORDINAL_DATE.matches(input)) { return STRICT_ORDINAL_DATE; - } else if ("strictOrdinalDateTime".equals(input) || "strict_ordinal_date_time".equals(input)) { + } else if (FormatNames.STRICT_ORDINAL_DATE_TIME.matches(input)) { return STRICT_ORDINAL_DATE_TIME; - } else if ("strictOrdinalDateTimeNoMillis".equals(input) || "strict_ordinal_date_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_ORDINAL_DATE_TIME_NO_MILLIS.matches(input)) { return STRICT_ORDINAL_DATE_TIME_NO_MILLIS; - } else if ("strictTime".equals(input) || "strict_time".equals(input)) { + } else if (FormatNames.STRICT_TIME.matches(input)) { return STRICT_TIME; - } else if ("strictTimeNoMillis".equals(input) || "strict_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_TIME_NO_MILLIS.matches(input)) { return STRICT_TIME_NO_MILLIS; - } else if ("strictTTime".equals(input) || "strict_t_time".equals(input)) { + } else if (FormatNames.STRICT_T_TIME.matches(input)) { return STRICT_T_TIME; - } else if ("strictTTimeNoMillis".equals(input) || "strict_t_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_T_TIME_NO_MILLIS.matches(input)) { return STRICT_T_TIME_NO_MILLIS; - } else if ("strictWeekDate".equals(input) || "strict_week_date".equals(input)) { + } else if (FormatNames.STRICT_WEEK_DATE.matches(input)) { return STRICT_WEEK_DATE; - } else if ("strictWeekDateTime".equals(input) || "strict_week_date_time".equals(input)) { + } else if (FormatNames.STRICT_WEEK_DATE_TIME.matches(input)) { return STRICT_WEEK_DATE_TIME; - } else if ("strictWeekDateTimeNoMillis".equals(input) || "strict_week_date_time_no_millis".equals(input)) { + } else if (FormatNames.STRICT_WEEK_DATE_TIME_NO_MILLIS.matches(input)) { return STRICT_WEEK_DATE_TIME_NO_MILLIS; - } else if ("strictWeekyear".equals(input) || "strict_weekyear".equals(input)) { + } else if (FormatNames.STRICT_WEEKYEAR.matches(input)) { return STRICT_WEEKYEAR; - } else if ("strictWeekyearWeek".equals(input) || "strict_weekyear_week".equals(input)) { + } else if (FormatNames.STRICT_WEEKYEAR_WEEK.matches(input)) { return STRICT_WEEKYEAR_WEEK; - } else if ("strictWeekyearWeekDay".equals(input) || "strict_weekyear_week_day".equals(input)) { + } else if (FormatNames.STRICT_WEEKYEAR_WEEK_DAY.matches(input)) { return STRICT_WEEKYEAR_WEEK_DAY; - } else if ("strictYear".equals(input) || "strict_year".equals(input)) { + } else if (FormatNames.STRICT_YEAR.matches(input)) { return STRICT_YEAR; - } else if ("strictYearMonth".equals(input) || "strict_year_month".equals(input)) { + } else if (FormatNames.STRICT_YEAR_MONTH.matches(input)) { return STRICT_YEAR_MONTH; - } else if ("strictYearMonthDay".equals(input) || "strict_year_month_day".equals(input)) { + } else if (FormatNames.STRICT_YEAR_MONTH_DAY.matches(input)) { return STRICT_YEAR_MONTH_DAY; } else { try { diff --git a/server/src/main/java/org/elasticsearch/common/time/FormatNames.java b/server/src/main/java/org/elasticsearch/common/time/FormatNames.java new file mode 100644 index 0000000000000..75fe74f42398c --- /dev/null +++ b/server/src/main/java/org/elasticsearch/common/time/FormatNames.java @@ -0,0 +1,167 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.time; + +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.util.LazyInitializable; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public enum FormatNames { + ISO8601(null, "iso8601"), + BASIC_DATE("basicDate", "basic_date"), + BASIC_DATE_TIME("basicDateTime", "basic_date_time"), + BASIC_DATE_TIME_NO_MILLIS("basicDateTimeNoMillis", "basic_date_time_no_millis"), + BASIC_ORDINAL_DATE("basicOrdinalDate", "basic_ordinal_date"), + BASIC_ORDINAL_DATE_TIME("basicOrdinalDateTime", "basic_ordinal_date_time"), + BASIC_ORDINAL_DATE_TIME_NO_MILLIS("basicOrdinalDateTimeNoMillis", "basic_ordinal_date_time_no_millis"), + BASIC_TIME("basicTime", "basic_time"), + BASIC_TIME_NO_MILLIS("basicTimeNoMillis", "basic_time_no_millis"), + BASIC_T_TIME("basicTTime", "basic_t_time"), + BASIC_T_TIME_NO_MILLIS("basicTTimeNoMillis", "basic_t_time_no_millis"), + BASIC_WEEK_DATE("basicWeekDate", "basic_week_date"), + BASIC_WEEK_DATE_TIME("basicWeekDateTime", "basic_week_date_time"), + BASIC_WEEK_DATE_TIME_NO_MILLIS("basicWeekDateTimeNoMillis", "basic_week_date_time_no_millis"), + DATE(null, "date"), + DATE_HOUR("dateHour", "date_hour"), + DATE_HOUR_MINUTE("dateHourMinute", "date_hour_minute"), + DATE_HOUR_MINUTE_SECOND("dateHourMinuteSecond", "date_hour_minute_second"), + DATE_HOUR_MINUTE_SECOND_FRACTION("dateHourMinuteSecondFraction", "date_hour_minute_second_fraction"), + DATE_HOUR_MINUTE_SECOND_MILLIS("dateHourMinuteSecondMillis", "date_hour_minute_second_millis"), + DATE_OPTIONAL_TIME("dateOptionalTime", "date_optional_time"), + DATE_TIME("dateTime", "date_time"), + DATE_TIME_NO_MILLIS("dateTimeNoMillis", "date_time_no_millis"), + HOUR(null, "hour"), + HOUR_MINUTE("hourMinute", "hour_minute"), + HOUR_MINUTE_SECOND("hourMinuteSecond", "hour_minute_second"), + HOUR_MINUTE_SECOND_FRACTION("hourMinuteSecondFraction", "hour_minute_second_fraction"), + HOUR_MINUTE_SECOND_MILLIS("hourMinuteSecondMillis", "hour_minute_second_millis"), + ORDINAL_DATE("ordinalDate", "ordinal_date"), + ORDINAL_DATE_TIME("ordinalDateTime", "ordinal_date_time"), + ORDINAL_DATE_TIME_NO_MILLIS("ordinalDateTimeNoMillis", "ordinal_date_time_no_millis"), + TIME(null, "time"), + TIME_NO_MILLIS("timeNoMillis", "time_no_millis"), + T_TIME("tTime", "t_time"), + T_TIME_NO_MILLIS("tTimeNoMillis", "t_time_no_millis"), + WEEK_DATE("weekDate", "week_date"), + WEEK_DATE_TIME("weekDateTime", "week_date_time"), + WEEK_DATE_TIME_NO_MILLIS("weekDateTimeNoMillis", "week_date_time_no_millis"), + WEEK_YEAR("weekyear", "week_year"), + WEEK_YEAR_WEEK("weekyearWeek", "weekyear_week"), + WEEKYEAR_WEEK_DAY("weekyearWeekDay", "weekyear_week_day"), + YEAR(null, "year"), + YEAR_MONTH("yearMonth", "year_month"), + YEAR_MONTH_DAY("yearMonthDay", "year_month_day"), + EPOCH_SECOND(null, "epoch_second"), + EPOCH_MILLIS(null, "epoch_millis"), + // strict date formats here, must be at least 4 digits for year and two for months and two for day" + STRICT_BASIC_WEEK_DATE("strictBasicWeekDate", "strict_basic_week_date"), + STRICT_BASIC_WEEK_DATE_TIME("strictBasicWeekDateTime", "strict_basic_week_date_time"), + STRICT_BASIC_WEEK_DATE_TIME_NO_MILLIS("strictBasicWeekDateTimeNoMillis", "strict_basic_week_date_time_no_millis"), + STRICT_DATE("strictDate", "strict_date"), + STRICT_DATE_HOUR("strictDateHour", "strict_date_hour"), + STRICT_DATE_HOUR_MINUTE("strictDateHourMinute", "strict_date_hour_minute"), + STRICT_DATE_HOUR_MINUTE_SECOND("strictDateHourMinuteSecond", "strict_date_hour_minute_second"), + STRICT_DATE_HOUR_MINUTE_SECOND_FRACTION("strictDateHourMinuteSecondFraction", "strict_date_hour_minute_second_fraction"), + STRICT_DATE_HOUR_MINUTE_SECOND_MILLIS("strictDateHourMinuteSecondMillis", "strict_date_hour_minute_second_millis"), + STRICT_DATE_OPTIONAL_TIME("strictDateOptionalTime", "strict_date_optional_time"), + STRICT_DATE_OPTIONAL_TIME_NANOS("strictDateOptionalTimeNanos", "strict_date_optional_time_nanos"), + STRICT_DATE_TIME("strictDateTime", "strict_date_time"), + STRICT_DATE_TIME_NO_MILLIS("strictDateTimeNoMillis", "strict_date_time_no_millis"), + STRICT_HOUR("strictHour", "strict_hour"), + STRICT_HOUR_MINUTE("strictHourMinute", "strict_hour_minute"), + STRICT_HOUR_MINUTE_SECOND("strictHourMinuteSecond", "strict_hour_minute_second"), + STRICT_HOUR_MINUTE_SECOND_FRACTION("strictHourMinuteSecondFraction", "strict_hour_minute_second_fraction"), + STRICT_HOUR_MINUTE_SECOND_MILLIS("strictHourMinuteSecondMillis", "strict_hour_minute_second_millis"), + STRICT_ORDINAL_DATE("strictOrdinalDate", "strict_ordinal_date"), + STRICT_ORDINAL_DATE_TIME("strictOrdinalDateTime", "strict_ordinal_date_time"), + STRICT_ORDINAL_DATE_TIME_NO_MILLIS("strictOrdinalDateTimeNoMillis", "strict_ordinal_date_time_no_millis"), + STRICT_TIME("strictTime", "strict_time"), + STRICT_TIME_NO_MILLIS("strictTimeNoMillis", "strict_time_no_millis"), + STRICT_T_TIME("strictTTime", "strict_t_time"), + STRICT_T_TIME_NO_MILLIS("strictTTimeNoMillis", "strict_t_time_no_millis"), + STRICT_WEEK_DATE("strictWeekDate", "strict_week_date"), + STRICT_WEEK_DATE_TIME("strictWeekDateTime", "strict_week_date_time"), + STRICT_WEEK_DATE_TIME_NO_MILLIS("strictWeekDateTimeNoMillis", "strict_week_date_time_no_millis"), + STRICT_WEEKYEAR("strictWeekyear", "strict_weekyear"), + STRICT_WEEKYEAR_WEEK("strictWeekyearWeek", "strict_weekyear_week"), + STRICT_WEEKYEAR_WEEK_DAY("strictWeekyearWeekDay", "strict_weekyear_week_day"), + STRICT_YEAR("strictYear", "strict_year"), + STRICT_YEAR_MONTH("strictYearMonth", "strict_year_month"), + STRICT_YEAR_MONTH_DAY("strictYearMonthDay", "strict_year_month_day"); + + private static final Set ALL_NAMES = Arrays.stream(values()) + .flatMap(n -> Stream.of(n.snakeCaseName, n.camelCaseName)) + .collect(Collectors.toSet()); + + private final String camelCaseName; + private final String snakeCaseName; + + // DateFormatters and FormatNames are being used even before the logging is initialized. + // If LogManager.getLogger is called before logging config is loaded + // it results in errors sent to status logger and startup to fail. + // Hence a lazy initialization. + private static final LazyInitializable deprecationLogger + = new LazyInitializable(() -> DeprecationLogger.getLogger(FormatNames.class)); + + FormatNames(String camelCaseName, String snakeCaseName) { + this.camelCaseName = camelCaseName; + this.snakeCaseName = snakeCaseName; + } + + public static boolean exist(String format) { + return ALL_NAMES.contains(format); + } + + public static FormatNames forName(String format) { + for (FormatNames name : values()) { + if (name.matches(format)) { + return name; + } + } + return null; + } + + public boolean matches(String format) { + return format.equals(camelCaseName) || format.equals(snakeCaseName); + } + + public boolean isCamelCase(String format) { + return format.equals(camelCaseName); + } + + private void deprecate() { + String msg = "Camel case format name {} is deprecated and will be removed in a future version. " + + "Use snake case name {} instead."; + deprecationLogger.getOrCompute() + .deprecate("camelCaseDateFormat", msg, camelCaseName, snakeCaseName); + } + + public String getSnakeCaseName() { + return snakeCaseName; + } + + public String getCamelCaseName() { + return camelCaseName; + } +} diff --git a/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java b/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java index 7bf26fd5e57a4..56840b3eb1c66 100644 --- a/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java +++ b/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java @@ -42,7 +42,7 @@ public class HotThreads { private static final Object mutex = new Object(); - private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("dateOptionalTime"); + private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("date_optional_time"); private int busiestThreads = 3; private TimeValue interval = new TimeValue(500, TimeUnit.MILLISECONDS); diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java index 2c8d08493864a..7c85f5582427b 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java @@ -57,7 +57,7 @@ public final class SnapshotInfo implements Comparable, ToXContent, public static final String CONTEXT_MODE_PARAM = "context_mode"; public static final String CONTEXT_MODE_SNAPSHOT = "SNAPSHOT"; - private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("strictDateOptionalTime"); + private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("strict_date_optional_time"); private static final String SNAPSHOT = "snapshot"; private static final String UUID = "uuid"; private static final String INDICES = "indices"; diff --git a/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java index d1a90328dfb65..fa5272955cf41 100644 --- a/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/joda/JodaDateMathParserTests.java @@ -36,7 +36,7 @@ public class JodaDateMathParserTests extends ESTestCase { - DateFormatter formatter = Joda.forPattern("dateOptionalTime||epoch_millis"); + DateFormatter formatter = Joda.forPattern("date_optional_time||epoch_millis"); DateMathParser parser = formatter.toDateMathParser(); void assertDateMathEquals(String toTest, String expected) { diff --git a/server/src/test/java/org/elasticsearch/common/joda/JodaTests.java b/server/src/test/java/org/elasticsearch/common/joda/JodaTests.java index 003785b3c87b3..1721ada86a310 100644 --- a/server/src/test/java/org/elasticsearch/common/joda/JodaTests.java +++ b/server/src/test/java/org/elasticsearch/common/joda/JodaTests.java @@ -40,7 +40,8 @@ public void testBasicTTimePattern() { DateFormatter formatter2 = Joda.forPattern("basicTTime"); assertEquals(formatter2.pattern(), "basicTTime"); assertEquals(formatter2.zone(), ZoneOffset.UTC); - + assertWarnings("Camel case format name basicTTime is deprecated and will be removed in a future version. " + + "Use snake case name basic_t_time instead."); DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, DateTimeZone.UTC); assertEquals("T102030.040Z", formatter1.formatJoda(dt)); assertEquals("T102030.040Z", formatter1.formatJoda(dt)); diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index a048edcfb7091..5c3718ee01dc8 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.common.time; +import org.elasticsearch.common.joda.Joda; import org.elasticsearch.test.ESTestCase; import java.time.Clock; @@ -376,4 +377,50 @@ public void testFractionalSeconds() { assertThat(instant.getNano(), is(123_456_789)); } } + + public void testCamelCaseDeprecation() { + String[] deprecatedNames = new String[]{ + "basicDate", "basicDateTime", "basicDateTimeNoMillis", "basicOrdinalDate", "basicOrdinalDateTime", + "basicOrdinalDateTimeNoMillis", "basicTime", "basicTimeNoMillis", "basicTTime", "basicTTimeNoMillis", + "basicWeekDate", "basicWeekDateTime", "basicWeekDateTimeNoMillis", "dateHour", "dateHourMinute", + "dateHourMinuteSecond", "dateHourMinuteSecondFraction", "dateHourMinuteSecondMillis", "dateOptionalTime", + "dateTime", "dateTimeNoMillis", "hourMinute", "hourMinuteSecond", "hourMinuteSecondFraction", "hourMinuteSecondMillis", + "ordinalDate", "ordinalDateTime", "ordinalDateTimeNoMillis", "timeNoMillis", + "tTime", "tTimeNoMillis", "weekDate", "weekDateTime", "weekDateTimeNoMillis", "weekyear", "weekyearWeek", "weekyearWeekDay", + "yearMonth", "yearMonthDay", "strictBasicWeekDate", "strictBasicWeekDateTime", + "strictBasicWeekDateTimeNoMillis", "strictDate", "strictDateHour", "strictDateHourMinute", "strictDateHourMinuteSecond", + "strictDateHourMinuteSecondFraction", "strictDateHourMinuteSecondMillis", "strictDateOptionalTime", + "strictDateOptionalTimeNanos", "strictDateTime", "strictDateTimeNoMillis", "strictHour", "strictHourMinute", + "strictHourMinuteSecond", "strictHourMinuteSecondFraction", "strictHourMinuteSecondMillis", "strictOrdinalDate", + "strictOrdinalDateTime", "strictOrdinalDateTimeNoMillis", "strictTime", "strictTimeNoMillis", "strictTTime", + "strictTTimeNoMillis", "strictWeekDate", "strictWeekDateTime", "strictWeekDateTimeNoMillis", "strictWeekyear", + "strictWeekyearWeek", + "strictWeekyearWeekDay", "strictYear", "strictYearMonth", "strictYearMonthDay" + }; + for (String name : deprecatedNames) { + String snakeCaseName = FormatNames.forName(name).getSnakeCaseName(); + + DateFormatter dateFormatter = DateFormatter.forPattern(name); + assertThat(dateFormatter.pattern(), equalTo(snakeCaseName)); + assertWarnings("Camel case format name " + name + " is deprecated and will be removed in a future version. " + + "Use snake case name " + snakeCaseName + " instead."); + + dateFormatter = DateFormatter.forPattern(snakeCaseName); + assertThat(dateFormatter.pattern(), equalTo(snakeCaseName)); + } + + for (String name : deprecatedNames) { + if (name.equals("strictDateOptionalTimeNanos") == false) { + DateFormatter dateFormatter = Joda.forPattern(name); + assertThat(dateFormatter.pattern(), equalTo(name)); + + String snakeCaseName = FormatNames.forName(name).getSnakeCaseName(); + assertWarnings("Camel case format name " + name + " is deprecated and will be removed in a future version. " + + "Use snake case name " + snakeCaseName + " instead."); + + dateFormatter = Joda.forPattern(snakeCaseName); + assertThat(dateFormatter.pattern(), equalTo(snakeCaseName)); + } + } + } } diff --git a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java index 8a4aacb6bbd19..96480ee60e7f6 100644 --- a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java @@ -34,7 +34,7 @@ public class JavaDateMathParserTests extends ESTestCase { - private final DateFormatter formatter = DateFormatter.forPattern("dateOptionalTime||epoch_millis"); + private final DateFormatter formatter = DateFormatter.forPattern("date_optional_time||epoch_millis"); private final DateMathParser parser = formatter.toDateMathParser(); public void testOverridingLocaleOrZoneAndCompositeRoundUpParser() { @@ -268,7 +268,7 @@ public void testTimestamps() { assertDateMathEquals("1418248078000||/m", "2014-12-10T21:47:00.000"); // also check other time units - DateMathParser parser = DateFormatter.forPattern("epoch_second||dateOptionalTime").toDateMathParser(); + DateMathParser parser = DateFormatter.forPattern("epoch_second||date_optional_time").toDateMathParser(); long datetime = parser.parse("1418248078", () -> 0).toEpochMilli(); assertDateEquals(datetime, "1418248078", "2014-12-10T21:47:58.000"); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/LongBoundsTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/LongBoundsTests.java index 69fbcdde27e80..42be589d4c06e 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/LongBoundsTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/LongBoundsTests.java @@ -98,7 +98,7 @@ public void testParseAndValidate() { new IndexSettings(IndexMetadata.builder("foo").settings(indexSettings).build(), indexSettings), BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, xContentRegistry(), writableRegistry(), null, null, () -> now, null, null, () -> true, null); - DateFormatter formatter = DateFormatter.forPattern("dateOptionalTime"); + DateFormatter formatter = DateFormatter.forPattern("date_optional_time"); DocValueFormat format = new DocValueFormat.DateTime(formatter, ZoneOffset.UTC, DateFieldMapper.Resolution.MILLISECONDS); LongBounds expected = randomParsedExtendedBounds();