harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496767 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/AbstractDocument.java test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java
Date Tue, 16 Jan 2007 17:01:42 GMT
Author: hindessm
Date: Tue Jan 16 09:01:40 2007
New Revision: 496767

URL: http://svn.apache.org/viewvc?view=rev&rev=496767
Log:
Applying patches from "[#HARMONY-2777] [classlib][swing]
j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw
ArrayIndexOutOfBoundsException rather than NPE".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java?view=diff&rev=496767&r1=496766&r2=496767
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
Tue Jan 16 09:01:40 2007
@@ -401,6 +401,9 @@
 
         @Override
         public int getEndOffset() {
+            if (elements.length == 0) {
+                throw new NullPointerException();
+            }
             return elements[elements.length - 1].getEndOffset();
         }
 
@@ -412,6 +415,9 @@
 
         @Override
         public int getStartOffset() {
+            if (elements.length == 0) {
+                throw new NullPointerException();
+            }
             return elements[0].getStartOffset();
         }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java?view=diff&rev=496767&r1=496766&r2=496767
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_BranchElementTest.java
Tue Jan 16 09:01:40 2007
@@ -243,9 +243,31 @@
         assertEquals(0, par.getStartOffset());
     }
 
+    // Regression for HARMONY-2777
+    public void testGetStartOffsetNoChildren() {
+        par = doc.new BranchElement(null, null);
+        try {
+            par.getStartOffset();
+            fail("NullPointerException is expected");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
     public void testGetEndOffset() {
         assertEquals(15, bidi.getEndOffset());
         assertEquals(15, par.getEndOffset());
+    }
+
+    // Regression for HARMONY-2777
+    public void testGetEndOffsetNoChildren() {
+        par = doc.new BranchElement(null, null);
+        try {
+            par.getEndOffset();
+            fail("NullPointerException is expected");
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     public void testGetElementCount() {



Mime
View raw message