Apache Lucene open-source search software
LUCENE-3344: Add workaround for ICU bug during ULocale classloading with some Java7-only locales
Uwe Schindler6edb2422f73e
diff --git a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.javaindex 2c7aa15f206..1a07710fe01 100644--- a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java@@ -353,6 +353,9 @@ public abstract class LuceneTestCase extends Assert {random.setSeed(staticSeed);random.initialized = true;}++ @Deprecated+ private static boolean icuTested = false;@BeforeClasspublic static void beforeClassLuceneTestCaseJ4() {@@ -401,7 +404,23 @@ public abstract class LuceneTestCase extends Assert {throw new RuntimeException(e);}}+savedLocale = Locale.getDefault();++ // START hack to init ICU safely before we randomize locales.+ // ICU fails during classloading when a special Java7-only locale is the default+ // see: http://bugs.icu-project.org/trac/ticket/8734+ if (!icuTested) {+ icuTested = true;+ try {+ Locale.setDefault(Locale.US);+ Class.forName("com.ibm.icu.util.ULocale");+ } catch (ClassNotFoundException cnfe) {+ // ignore if no ICU is in classpath+ }+ }+ // END hack+locale = TEST_LOCALE.equals("random") ? randomLocale(random) : localeForName(TEST_LOCALE);Locale.setDefault(locale);savedTimeZone = TimeZone.getDefault();