]> granicus.if.org Git - icu/commitdiff
ICU-9880 Guard against a degenerate collator where some script boundary strings are...
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 7 Feb 2013 00:55:27 +0000 (00:55 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Thu, 7 Feb 2013 00:55:27 +0000 (00:55 +0000)
X-SVN-Rev: 33134

icu4j/main/classes/collate/src/com/ibm/icu/text/AlphabeticIndex.java

index 35263d354370320f984949efbb59b30b2a14d233..860ef795dd32f80a7143fa3ef2a14814c61a3cad 100644 (file)
@@ -275,6 +275,19 @@ public final class AlphabeticIndex<V> implements Iterable<Bucket<V>> {
                 firstCharsInScripts.remove(hanIndex);
             }
         }
+        // Guard against a degenerate collator where
+        // some script boundary strings are primary ignorable.
+        for (;;) {
+            if (firstCharsInScripts.isEmpty()) {
+                throw new IllegalArgumentException(
+                        "AlphabeticIndex requires some non-ignorable script boundary strings");
+            }
+            if (collatorPrimaryOnly.compare(firstCharsInScripts.get(0), "") == 0) {
+                firstCharsInScripts.remove(0);
+            } else {
+                break;
+            }
+        }
 
         if (exemplarChars != null) {
             addLabels(exemplarChars);