Skip to content

Commit a146a0f

Browse files
committed
ICU-23124 Fix exception type in BreakIterator for OOB index values
1 parent 55c7cea commit a146a0f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

icu4j/main/core/src/main/java/com/ibm/icu/text/RuleBasedBreakIterator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ public int preceding(int offset) {
524524

525525

526526
/**
527-
* Throw IllegalArgumentException unless begin <= offset < end.
527+
* Throw IndexOutOfBoundsException unless begin <= offset < end.
528528
* @stable ICU 2.0
529529
*/
530530
protected static final void checkOffset(int offset, CharacterIterator text) {
531531
if (offset < text.getBeginIndex() || offset > text.getEndIndex()) {
532-
throw new IllegalArgumentException("offset out of bounds");
532+
throw new IndexOutOfBoundsException("offset out of bounds");
533533
}
534534
}
535535

icu4j/main/core/src/test/java/com/ibm/icu/dev/test/rbbi/BreakIteratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void TestBug4153072() {
158158
errln("Didn't get exception with offset = " + index +
159159
" and begin index = " + begin);
160160
}
161-
catch (IllegalArgumentException e) {
161+
catch (IndexOutOfBoundsException e) {
162162
if (index >= begin)
163163
errln("Got exception with offset = " + index +
164164
" and begin index = " + begin);

0 commit comments

Comments
 (0)