ICU-4735 ULocale getTableString will return null instead of NullPointerException when input String is null.

X-SVN-Rev: 26460
This commit is contained in:
Jason Spieth 2009-07-30 20:03:57 +00:00
parent 6c22ca75fe
commit 496eead7a6
2 changed files with 20 additions and 5 deletions

View File

@ -2192,15 +2192,15 @@ public final class ULocale implements Serializable {
* Utility to fetch locale display data from resource bundle tables.
*/
private static String getTableString(String tableName, String subtableName, String item, String displayLocaleID) {
if (item.length() > 0) {
try {
try {
if (item.length() > 0) {
ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.
getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, displayLocaleID);
return getTableString(tableName, subtableName, item, bundle);
} catch (Exception e) {
// System.out.println("gtsu: " + e.getMessage());
}
}
} catch (Exception e) {
// System.out.println("gtsu: " + e.getMessage());
}
return item;
}

View File

@ -3848,4 +3848,19 @@ public class ULocaleTest extends TestFmwk {
}
}
}
/*
* Test that if you use any locale without keyword that you will get a NULL
* string returned and not throw and exception.
*/
public void Test4735()
{
try {
new ULocale("und").getDisplayKeywordValue("calendar",ULocale.GERMAN);
new ULocale("en").getDisplayKeywordValue("calendar",ULocale.GERMAN);
} catch (Exception e) {
errln("Unexpected exception: " + e.getMessage());
}
}
}