Skip to content

Commit f9aa6f4

Browse files
authored
Always use CLDR locale on ES v9 (#113184)
Regardless of JDK version, ES should always use CLDR locale database from 9.0.0. This also removes IsoCalendarDataProvider used to override week-date calculations for the root locale only.
1 parent 9da39f0 commit f9aa6f4

File tree

16 files changed

+51
-180
lines changed

16 files changed

+51
-180
lines changed

build-tools-internal/src/main/groovy/elasticsearch.ide.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
168168
vmParameters = [
169169
'-ea',
170170
'-Djava.security.manager=allow',
171-
'-Djava.locale.providers=SPI,CLDR',
171+
'-Djava.locale.providers=CLDR',
172172
'-Des.nativelibs.path="' + testLibraryPath + '"',
173173
// TODO: only open these for mockito when it is modularized
174174
'--add-opens=java.base/java.security.cert=ALL-UNNAMED',

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void execute(Task t) {
9393
mkdirs(test.getWorkingDir().toPath().resolve("temp").toFile());
9494

9595
// TODO remove once jvm.options are added to test system properties
96-
test.systemProperty("java.locale.providers", "SPI,CLDR");
96+
test.systemProperty("java.locale.providers", "CLDR");
9797
}
9898
});
9999
test.getJvmArgumentProviders().add(nonInputProperties);

distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/SystemJvmOptions.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.common.settings.Settings;
1313
import org.elasticsearch.common.util.concurrent.EsExecutors;
14-
import org.elasticsearch.core.UpdateForV9;
1514

1615
import java.util.List;
1716
import java.util.Map;
@@ -61,7 +60,7 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
6160
"-Dlog4j.shutdownHookEnabled=false",
6261
"-Dlog4j2.disable.jmx=true",
6362
"-Dlog4j2.formatMsgNoLookups=true",
64-
"-Djava.locale.providers=" + getLocaleProviders(),
63+
"-Djava.locale.providers=CLDR",
6564
maybeEnableNativeAccess(),
6665
maybeOverrideDockerCgroup(distroType),
6766
maybeSetActiveProcessorCount(nodeSettings),
@@ -73,16 +72,6 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
7372
).filter(e -> e.isEmpty() == false).collect(Collectors.toList());
7473
}
7574

76-
@UpdateForV9 // only use CLDR in v9+
77-
private static String getLocaleProviders() {
78-
/*
79-
* Specify SPI to load IsoCalendarDataProvider (see #48209), specifying the first day of week as Monday.
80-
* When on pre-23, use COMPAT instead to maintain existing date formats as much as we can.
81-
* When on JDK 23+, use the default CLDR locale database, as COMPAT was removed in JDK 23.
82-
*/
83-
return Runtime.version().feature() >= 23 ? "SPI,CLDR" : "SPI,COMPAT";
84-
}
85-
8675
/*
8776
* The virtual file /proc/self/cgroup should list the current cgroup
8877
* membership. For each hierarchy, you can follow the cgroup path from

modules/aggregations/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ dependencies {
4545
compileOnly(project(':modules:lang-painless:spi'))
4646
clusterModules(project(':modules:lang-painless'))
4747
}
48+
49+
tasks.named("yamlRestCompatTestTransform").configure({ task ->
50+
task.skipTest("aggregations/date_agg_per_day_of_week/Date aggregartion per day of week", "week-date behaviour has changed")
51+
})

modules/aggregations/src/yamlRestTest/resources/rest-api-spec/test/aggregations/date_agg_per_day_of_week.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

modules/ingest-common/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ tasks.named("thirdPartyAudit").configure {
5050
'org.apache.commons.logging.LogFactory',
5151
)
5252
}
53+
54+
tasks.named("yamlRestCompatTestTransform").configure({ task ->
55+
task.skipTest("ingest/30_date_processor/Test week based date parsing", "week-date behaviour has changed")
56+
})

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateFormatTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ public void testParseJavaDefaultYear() {
7575
public void testParseWeekBasedYearAndWeek() {
7676
String format = "YYYY-ww";
7777
ZoneId timezone = DateUtils.of("Europe/Amsterdam");
78-
Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ROOT);
78+
Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ENGLISH);
7979
ZonedDateTime dateTime = javaFunction.apply("2020-33");
80-
assertThat(dateTime, equalTo(ZonedDateTime.of(2020, 8, 10, 0, 0, 0, 0, timezone)));
80+
assertThat(dateTime, equalTo(ZonedDateTime.of(2020, 8, 9, 0, 0, 0, 0, timezone)));
8181
}
8282

8383
public void testParseWeekBasedYear() {
8484
String format = "YYYY";
8585
ZoneId timezone = DateUtils.of("Europe/Amsterdam");
86-
Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ROOT);
86+
Function<String, ZonedDateTime> javaFunction = DateFormat.Java.getFunction(format, timezone, Locale.ENGLISH);
8787
ZonedDateTime dateTime = javaFunction.apply("2019");
88-
assertThat(dateTime, equalTo(ZonedDateTime.of(2018, 12, 31, 0, 0, 0, 0, timezone)));
88+
assertThat(dateTime, equalTo(ZonedDateTime.of(2018, 12, 30, 0, 0, 0, 0, timezone)));
8989
}
9090

9191
public void testParseWeekBasedWithLocale() {

modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/30_date_processor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ teardown:
246246
}
247247
- length: { docs: 1 }
248248
- match: { docs.0.doc._source.date_source_field: "2020-33" }
249-
- match: { docs.0.doc._source.date_target_field: "2020-08-10T00:00:00.000Z" }
249+
- match: { docs.0.doc._source.date_target_field: "2020-08-09T00:00:00.000Z" }
250250
- length: { docs.0.doc._ingest: 1 }
251251
- is_true: docs.0.doc._ingest.timestamp
252252

@@ -262,7 +262,7 @@ teardown:
262262
index: test
263263
id: "1"
264264
- match: { _source.date_source_field: "2020-33" }
265-
- match: { _source.date_target_field: "2020-08-10T00:00:00.000Z" }
265+
- match: { _source.date_target_field: "2020-08-09T00:00:00.000Z" }
266266

267267
---
268268
"Test week based date parsing with locale":

server/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@
404404
exports org.elasticsearch.telemetry;
405405
exports org.elasticsearch.telemetry.metric;
406406

407-
provides java.util.spi.CalendarDataProvider with org.elasticsearch.common.time.IsoCalendarDataProvider;
408407
provides org.elasticsearch.xcontent.ErrorOnUnknown with org.elasticsearch.common.xcontent.SuggestingErrorOnUnknown;
409408
provides org.elasticsearch.xcontent.XContentBuilderExtension with org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
410409
provides org.elasticsearch.cli.CliToolProvider

server/src/main/java/org/elasticsearch/common/time/DateFormatters.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,8 +2324,6 @@ static DateFormatter forPattern(String input) {
23242324
} else if (FormatNames.STRICT_YEAR_MONTH_DAY.matches(input)) {
23252325
return STRICT_YEAR_MONTH_DAY;
23262326
} else {
2327-
DateUtils.checkTextualDateFormats(input);
2328-
23292327
try {
23302328
return newDateFormatter(
23312329
input,

0 commit comments

Comments
 (0)