public void testThreadSafe() throws Exception {
   int iters = 20 * RANDOM_MULTIPLIER;
   for (int i = 0; i < iters; i++) {
     Locale locale = Locale.GERMAN;
     Collator collator = Collator.getInstance(locale);
     collator.setStrength(Collator.IDENTICAL);
     assertThreadSafe(new ICUCollationKeyAnalyzer(TEST_VERSION_CURRENT, collator));
   }
 }
 public static TermsFacetComparator getInstance(
     String type, boolean reverse, ULocale locale, String rules, int decomp, int strength) {
   if (locale == null) {
     locale = ULocale.getDefault();
   }
   if ("count".equals(type) || "reverse_count".equals(type) || "reverseCount".equals(type)) {
     if (type.startsWith("reverse")) {
       reverse = true; // compatibility mode
     }
     return new TermsFacetCountComparator("count", reverse);
   } else if ("term".equals(type) || "reverse_term".equals(type) || "reverseTerm".equals(type)) {
     if (type.startsWith("reverse")) {
       reverse = true; // compatibility mode
     }
     TermsFacetCollationComparator comparator = new TermsFacetCollationComparator("term", reverse);
     comparator.setLocale(locale);
     Collator collator = Collator.getInstance(locale);
     if (rules == null) {
       if (strength != -1) {
         collator.setStrength(strength);
       }
       if (decomp != -1) {
         collator.setDecomposition(decomp);
       }
       comparator.setCollator(collator);
     } else {
       try {
         comparator.setRules(rules);
         RuleBasedCollator rc = (RuleBasedCollator) collator;
         comparator.setCollator(new RuleBasedCollator(rc.getRules() + rules));
       } catch (Exception e) {
         comparator.setCollator(Collator.getInstance(locale));
       }
     }
     return comparator;
   }
   throw new ElasticSearchIllegalArgumentException(
       "No type argument match for terms facet comparator [" + type + "]");
 }