Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6970930

RuleBasedCollator.compare(String,null) throws IAE (should be NPE)

XMLWordPrintable

    • b116
    • generic
    • generic
    • Verified

      Run this test case with jdk7-b100:

      import java.text.*;

      public class Test {
          public static void main(String[] args) {
              Collator c = Collator.getInstance();
              c.compare("foo", "bar");
              c.compare("foo", null);
          }
      }

      and it fails with this:

      Exception in thread "main" java.lang.IllegalArgumentException
              at sun.text.normalizer.ReplaceableUCharacterIterator.<init>(ReplaceableUCharacterIterator.java:60)
              at sun.text.normalizer.UCharacterIterator.getInstance(UCharacterIterator.java:84)
              at sun.text.normalizer.NormalizerBase.setText(NormalizerBase.java:1002)
              at java.text.CollationElementIterator.setText(CollationElementIterator.java:497)
              at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:372)
              at Test.main(Test2.java:8)

      It shoud of course fail with NullPointerException (not IAE).

            peytoia Yuka Kamiya (Inactive)
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: