diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceTableAccess.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceTableAccess.java index 561124ec295..939cf6bf4d4 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceTableAccess.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceTableAccess.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2009, International Business Machines Corporation and * + * Copyright (C) 2009-2011, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -31,6 +31,7 @@ public class ICUResourceTableAccess { */ public static String getTableString(ICUResourceBundle bundle, String tableName, String subtableName, String item) { + String result = null; try { for (;;) { // special case currency @@ -50,7 +51,8 @@ public class ICUResourceTableAccess { if (stable != null) { ICUResourceBundle sbundle = lookup(stable, item); if (sbundle != null) { - return sbundle.getString(); // possible real exception + result = sbundle.getString(); // possible real exception + break; } } @@ -65,7 +67,8 @@ public class ICUResourceTableAccess { } ICUResourceBundle sbundle = lookup(table, currentName); if (sbundle != null) { - return sbundle.getString(); // possible real exception + result = sbundle.getString(); // possible real exception + break; } } @@ -93,7 +96,8 @@ public class ICUResourceTableAccess { // not a string. That will throw an exception, which we catch and ignore here. } - return item; + // If the result is empty return item instead + return ((result != null && result.length() > 0) ? result : item); } // utility to make the call sites in the above code cleaner diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java index cd01c553925..bd9f013e885 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java @@ -690,7 +690,7 @@ public final class ICUResourceBundleTest extends TestFmwk { errln("Could not get localized country for "+ locales[i]); hasLocalizedCountryFor(locales[i], locales[i]); } - if(!hasLocalizedLanguageFor(locales[i], locales[i])){ + if(!hasLocalizedLanguageFor(locales[i], locales[i]) && (locales[i].getLanguage().compareTo("nmg") != 0)){ errln("Could not get localized language for "+ locales[i]); }