From 18bf8f155e5721dd7488a377e4387d48d7c92235 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sun, 16 Oct 2011 15:45:10 +0000 Subject: [PATCH] LUCENE-3521: revert the revert of the hack in LuceneTestCase because ICU still has bugs with java7 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1184851 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/util/LuceneTestCase.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java index e510a0ef356..f9df8e5f15b 100644 --- a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java @@ -324,6 +324,9 @@ public abstract class LuceneTestCase extends Assert { random.setSeed(staticSeed); random.initialized = true; } + + @Deprecated + private static boolean icuTested = false; @BeforeClass public static void beforeClassLuceneTestCaseJ4() { @@ -376,6 +379,20 @@ public abstract class LuceneTestCase extends Assert { 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();