8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
Reviewed-by: okutsu
This commit is contained in:
parent
f1f634eb38
commit
799007c62d
@ -42,7 +42,9 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.spi.DecimalFormatSymbolsProvider;
|
import java.text.spi.DecimalFormatSymbolsProvider;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@ -554,20 +556,31 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||||||
}
|
}
|
||||||
ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(locale);
|
ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(locale);
|
||||||
data = new Object[3];
|
data = new Object[3];
|
||||||
|
|
||||||
|
// NumberElements look up. First, try the Unicode extension
|
||||||
|
String numElemKey;
|
||||||
String numberType = locale.getUnicodeLocaleType("nu");
|
String numberType = locale.getUnicodeLocaleType("nu");
|
||||||
StringBuilder numElemKey =
|
if (numberType != null) {
|
||||||
new StringBuilder(numberType != null ?
|
numElemKey = numberType + ".NumberElements";
|
||||||
numberType : rb.getString("DefaultNumberingSystem"));
|
if (rb.containsKey(numElemKey)) {
|
||||||
if (numElemKey.length() != 0) {
|
data[0] = rb.getStringArray(numElemKey);
|
||||||
numElemKey.append(".");
|
|
||||||
}
|
}
|
||||||
numElemKey.append("NumberElements");
|
}
|
||||||
try {
|
|
||||||
data[0] = rb.getStringArray(numElemKey.toString());
|
// Next, try DefaultNumberingSystem value
|
||||||
} catch (MissingResourceException mre) {
|
if (data[0] == null && rb.containsKey("DefaultNumberingSystem")) {
|
||||||
// numberType must be bogus. Use the last resort numbering system.
|
numElemKey = rb.getString("DefaultNumberingSystem") + ".NumberElements";
|
||||||
|
if (rb.containsKey(numElemKey)) {
|
||||||
|
data[0] = rb.getStringArray(numElemKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last resort. No need to check the availability.
|
||||||
|
// Just let it throw MissingResourceException when needed.
|
||||||
|
if (data[0] == null) {
|
||||||
data[0] = rb.getStringArray("NumberElements");
|
data[0] = rb.getStringArray("NumberElements");
|
||||||
}
|
}
|
||||||
|
|
||||||
needCacheUpdate = true;
|
needCacheUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@ public class LocaleProviders {
|
|||||||
tzNameTest(args[1]);
|
tzNameTest(args[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "bug8001440Test":
|
||||||
|
bug8001440Test();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Test method '"+methodName+"' not found.");
|
throw new RuntimeException("Test method '"+methodName+"' not found.");
|
||||||
}
|
}
|
||||||
@ -93,4 +97,10 @@ public class LocaleProviders {
|
|||||||
throw new RuntimeException("JRE's localized time zone name for "+id+" could not be retrieved. Returned name was: "+tzName);
|
throw new RuntimeException("JRE's localized time zone name for "+id+" could not be retrieved. Returned name was: "+tzName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void bug8001440Test() {
|
||||||
|
Locale locale = Locale.forLanguageTag("th-TH-u-nu-hoge");
|
||||||
|
NumberFormat nf = NumberFormat.getInstance(locale);
|
||||||
|
String nu = nf.format(1234560);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# @test
|
# @test
|
||||||
# @bug 6336885 7196799 7197573 7198834 8000245 8000615
|
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440
|
||||||
# @summary tests for "java.locale.providers" system property
|
# @summary tests for "java.locale.providers" system property
|
||||||
# @compile -XDignore.symbol.file LocaleProviders.java
|
# @compile -XDignore.symbol.file LocaleProviders.java
|
||||||
# @run shell/timeout=600 LocaleProviders.sh
|
# @run shell/timeout=600 LocaleProviders.sh
|
||||||
@ -245,4 +245,12 @@ PARAM2=
|
|||||||
PARAM3=
|
PARAM3=
|
||||||
runTest
|
runTest
|
||||||
|
|
||||||
|
# testing 8001440 fix.
|
||||||
|
METHODNAME=bug8001440Test
|
||||||
|
PREFLIST=CLDR
|
||||||
|
PARAM1=
|
||||||
|
PARAM2=
|
||||||
|
PARAM3=
|
||||||
|
runTest
|
||||||
|
|
||||||
exit $result
|
exit $result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user