diff options
author | Elliott Hughes <enh@google.com> | 2014-04-21 16:40:44 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-04-21 16:49:28 -0700 |
commit | 3e3ea7374ec174050c91066bf2e3b154bffd4e96 (patch) | |
tree | 0ccc0b0e99a68dacdec3d898eedf142e23cc8565 | |
parent | abe8c4ce82803a2044f23996872d5a7fd5d2328b (diff) | |
download | libcore-3e3ea7374ec174050c91066bf2e3b154bffd4e96.zip libcore-3e3ea7374ec174050c91066bf2e3b154bffd4e96.tar.gz libcore-3e3ea7374ec174050c91066bf2e3b154bffd4e96.tar.bz2 |
Allow empty rules in a RuleBasedCollator.
This is allowed by the CLDR specification, and we were already allowing
most forms of empty rules, just not the zero-length string.
Change-Id: I3c2a020aac23e54f8044defbfe2e2a5b600e454c
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java | 13 | ||||
-rw-r--r-- | luni/src/main/java/java/text/RuleBasedCollator.java | 4 |
2 files changed, 4 insertions, 13 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java index 89dfea9..f5a8057 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java @@ -250,14 +250,9 @@ public class RuleBasedCollatorTest extends TestCase { } } - public void testEmptyStringException() { - //Regression for HARMONY-241 - try { - new RuleBasedCollator(""); - fail(); - } catch (ParseException e) { - assertEquals("java.text.ParseException", e.getClass().getName()); - assertEquals(0, e.getErrorOffset()); - } + public void testEmptyRules() throws Exception { + new RuleBasedCollator(""); + new RuleBasedCollator(" "); + new RuleBasedCollator("# This is a comment."); } } diff --git a/luni/src/main/java/java/text/RuleBasedCollator.java b/luni/src/main/java/java/text/RuleBasedCollator.java index db1da5f..90dbd86 100644 --- a/luni/src/main/java/java/text/RuleBasedCollator.java +++ b/luni/src/main/java/java/text/RuleBasedCollator.java @@ -101,10 +101,6 @@ public class RuleBasedCollator extends Collator { if (rules == null) { throw new NullPointerException("rules == null"); } - // icu4c is fine with empty rules, but the RI isn't. - if (rules.isEmpty()) { - throw new ParseException("empty rules", 0); - } try { icuColl = new RuleBasedCollatorICU(rules); } catch (Exception e) { |