Skip to content

Commit b68f7ed

Browse files
authored
Pass java.locale.providers=COMPAT to Java 9 onwards (elastic#28080)
Java 9 added some enhancements to the internationalization support that impact our date parsing support. To ensure flawless BWC and consistent behavior going forward Java 9 runtimes requrie the system property `java.locale.providers=COMPAT` to be set. Closes elastic#10984
1 parent ca32519 commit b68f7ed

File tree

3 files changed

+41
-38
lines changed

3 files changed

+41
-38
lines changed

core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -220,43 +220,6 @@ public void testSimpleDateRange() throws Exception {
220220
assertHitCount(searchResponse, 2L);
221221
}
222222

223-
public void testLocaleDependentDate() throws Exception {
224-
assumeFalse("Locals are buggy on JDK9EA", Constants.JRE_IS_MINIMUM_JAVA9 && systemPropertyAsBoolean("tests.security.manager", false));
225-
assertAcked(prepareCreate("test")
226-
.addMapping("type1",
227-
jsonBuilder().startObject()
228-
.startObject("type1")
229-
.startObject("properties")
230-
.startObject("date_field")
231-
.field("type", "date")
232-
.field("format", "E, d MMM yyyy HH:mm:ss Z")
233-
.field("locale", "de")
234-
.endObject()
235-
.endObject()
236-
.endObject()
237-
.endObject()));
238-
ensureGreen();
239-
for (int i = 0; i < 10; i++) {
240-
client().prepareIndex("test", "type1", "" + i).setSource("date_field", "Mi, 06 Dez 2000 02:55:00 -0800").execute().actionGet();
241-
client().prepareIndex("test", "type1", "" + (10 + i)).setSource("date_field", "Do, 07 Dez 2000 02:55:00 -0800").execute().actionGet();
242-
}
243-
244-
refresh();
245-
for (int i = 0; i < 10; i++) {
246-
SearchResponse searchResponse = client().prepareSearch("test")
247-
.setQuery(QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Do, 07 Dez 2000 00:00:00 -0800"))
248-
.execute().actionGet();
249-
assertHitCount(searchResponse, 10L);
250-
251-
252-
searchResponse = client().prepareSearch("test")
253-
.setQuery(QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Fr, 08 Dez 2000 00:00:00 -0800"))
254-
.execute().actionGet();
255-
assertHitCount(searchResponse, 20L);
256-
257-
}
258-
}
259-
260223
public void testSimpleTerminateAfterCount() throws Exception {
261224
prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
262225
ensureGreen();
@@ -273,7 +236,6 @@ public void testSimpleTerminateAfterCount() throws Exception {
273236
refresh();
274237

275238
SearchResponse searchResponse;
276-
277239
for (int i = 1; i <= max; i++) {
278240
searchResponse = client().prepareSearch("test")
279241
.setQuery(QueryBuilders.rangeQuery("field").gte(1).lte(max))

distribution/src/main/resources/config/jvm.options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ ${heap.dump.path}
9494

9595
# JDK 9+ GC logging
9696
9-:-Xlog:gc*,gc+age=trace,safepoint:file=${loggc}:utctime,pid,tags:filecount=32,filesize=64m
97+
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
98+
# time/date parsing will break in an incompatible way for some date patterns and locals
99+
9-:-Djava.locale.providers=COMPAT
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
"Test Index and Search locale dependent mappings / dates":
3+
- skip:
4+
version: " - 6.99.99"
5+
reason: JDK9 only supports this with a special sysproperty added in 7.0.0
6+
- do:
7+
indices.create:
8+
index: test_index
9+
body:
10+
settings:
11+
number_of_shards: 1
12+
mappings:
13+
doc:
14+
properties:
15+
date_field:
16+
type: date
17+
format: "E, d MMM yyyy HH:mm:ss Z"
18+
locale: "de"
19+
- do:
20+
bulk:
21+
refresh: true
22+
body:
23+
- '{"index": {"_index": "test_index", "_type": "doc", "_id": "1"}}'
24+
- '{"date_field": "Mi, 06 Dez 2000 02:55:00 -0800"}'
25+
- '{"index": {"_index": "test_index", "_type": "doc", "_id": "2"}}'
26+
- '{"date_field": "Do, 07 Dez 2000 02:55:00 -0800"}'
27+
28+
- do:
29+
search:
30+
index: test_index
31+
body: {"query" : {"range" : {"date_field" : {"gte": "Di, 05 Dez 2000 02:55:00 -0800", "lte": "Do, 07 Dez 2000 00:00:00 -0800"}}}}
32+
- match: { hits.total: 1 }
33+
34+
- do:
35+
search:
36+
index: test_index
37+
body: {"query" : {"range" : {"date_field" : {"gte": "Di, 05 Dez 2000 02:55:00 -0800", "lte": "Fr, 08 Dez 2000 00:00:00 -0800"}}}}
38+
- match: { hits.total: 2 }

0 commit comments

Comments
 (0)