You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2007/01/13 17:22:56 UTC
svn commit: r495916 - in /harmony/enhanced/classlib/trunk/modules/swing/src:
main/java/common/javax/swing/text/GapContent.java
test/api/java/common/javax/swing/text/GapContentTest.java
Author: hindessm
Date: Sat Jan 13 08:22:55 2007
New Revision: 495916
URL: http://svn.apache.org/viewvc?view=rev&rev=495916
Log:
Applying patch from "[#HARMONY-2566] [classlib][swing]
j.s.text.GapContent.getChars throws NPE rather than BadLocationException".
Modified:
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java
harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/GapContentTest.java
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java?view=diff&rev=495916&r1=495915&r2=495916
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java Sat Jan 13 08:22:55 2007
@@ -143,7 +143,7 @@
throw new BadLocationException("Length must be non-negative",
length);
}
- if (offset < 0 || offset + length > length()) {
+ if (offset < 0 || length > length() - offset) {
throw new BadLocationException("Invalid start position", offset);
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/GapContentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/GapContentTest.java?view=diff&rev=495916&r1=495915&r2=495916
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/GapContentTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/GapContentTest.java Sat Jan 13 08:22:55 2007
@@ -221,6 +221,23 @@
isContentArraySame(false);
}
+ // Regression for HARMONY-2566
+ public void testGetCharsMaxInterger() {
+ try {
+ content.getChars(1, Integer.MAX_VALUE, null);
+ fail("BadLocationException is expected");
+ } catch (BadLocationException e) {
+ }
+ }
+
+ public void testGetCharsNullSegment() throws BadLocationException {
+ try {
+ content.getChars(1, 1, null);
+ fail("NullPointerException is expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
public void testCreatePositionBeforeUndo() throws BadLocationException {
UndoableEdit ue = content.remove(3, 8);
Position pos = content.createPosition(3);