mirror of https://github.com/apache/lucene.git
LUCENE-6978: Fix usage of Locale#toString in DIH
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1726311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09e4595501
commit
4efccce1f1
|
@ -135,14 +135,14 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
|
|||
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH", defaultLocale);
|
||||
String sdf = sdfDate.format(twoDaysAgo(defaultLocale, TimeZone.getDefault()));
|
||||
String dfe = dateFormatEval.evaluate(
|
||||
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale + "'", context);
|
||||
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale.toLanguageTag() + "'", context);
|
||||
assertEquals(sdf,dfe);
|
||||
for(String tzStr : TimeZone.getAvailableIDs()) {
|
||||
TimeZone tz = TimeZone.getTimeZone(tzStr);
|
||||
sdfDate.setTimeZone(tz);
|
||||
sdf = sdfDate.format(twoDaysAgo(defaultLocale, tz));
|
||||
dfe = dateFormatEval.evaluate(
|
||||
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale + "','" + tzStr + "'", context);
|
||||
"'NOW-2DAYS','yyyy-MM-dd HH','" + defaultLocale.toLanguageTag() + "','" + tzStr + "'", context);
|
||||
assertEquals(sdf,dfe);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
|
|||
dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", context));
|
||||
assertEquals(
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale).format(d),
|
||||
dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale + "'", context));
|
||||
dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale.toLanguageTag() + "'", context));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", defaultLocale);
|
||||
for(String tzStr : TimeZone.getAvailableIDs()) {
|
||||
TimeZone tz = TimeZone.getTimeZone(tzStr);
|
||||
|
@ -165,7 +165,7 @@ public class TestBuiltInEvaluators extends AbstractDataImportHandlerTestCase {
|
|||
assertEquals(
|
||||
sdf.format(d),
|
||||
dateFormatEval.evaluate(
|
||||
"A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale + "', '" + tzStr + "'", context));
|
||||
"A.key, 'yyyy-MM-dd HH:mm','" + defaultLocale.toLanguageTag() + "', '" + tzStr + "'", context));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TestVariableResolverEndToEnd extends AbstractDIHJdbcTestCase {
|
|||
|
||||
@Override
|
||||
protected String generateConfig() {
|
||||
String thirdLocaleParam = random().nextBoolean() ? "" : (", '" + Locale.getDefault() + "'");
|
||||
String thirdLocaleParam = random().nextBoolean() ? "" : (", '" + Locale.getDefault().toLanguageTag() + "'");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<dataConfig> \n");
|
||||
sb.append("<dataSource name=\"hsqldb\" driver=\"${dataimporter.request.dots.in.hsqldb.driver}\" url=\"jdbc:hsqldb:mem:.\" /> \n");
|
||||
|
|
|
@ -163,7 +163,7 @@ public final class SolrCellBuilder implements CommandBuilder {
|
|||
}
|
||||
this.solrContentHandlerFactory = getSolrContentHandlerFactory(factoryClass, dateFormats, config);
|
||||
|
||||
this.locale = getLocale(getConfigs().getString(config, "locale", ""));
|
||||
this.locale = getLocale(getConfigs().getString(config, "locale", null));
|
||||
|
||||
this.mediaTypeToParserMap = new HashMap<>();
|
||||
//MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes(); // FIXME getMediaTypeRegistry.normalize()
|
||||
|
@ -329,7 +329,7 @@ public final class SolrCellBuilder implements CommandBuilder {
|
|||
|
||||
@SuppressForbidden(reason = "Usage of outdated locale parsing with Locale#toString() because of backwards compatibility")
|
||||
private Locale getLocale(String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
if (name == null) {
|
||||
return Locale.ROOT;
|
||||
}
|
||||
for (Locale locale : Locale.getAvailableLocales()) {
|
||||
|
|
Loading…
Reference in New Issue