harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r501905 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/undo/UndoManager.java test/api/java/common/javax/swing/undo/UndoManagerTest.java
Date Wed, 31 Jan 2007 17:14:38 GMT
Author: ayza
Date: Wed Jan 31 09:14:34 2007
New Revision: 501905

URL: http://svn.apache.org/viewvc?view=rev&rev=501905
Log:
Applying patch from HARMONY-2612 ([classlib][swing] j.s.undo.UndoManager.redoTo doesn't throw
ArrayIndexOutOfBoundsException)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/UndoManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java?view=diff&rev=501905&r1=501904&r2=501905
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
Wed Jan 31 09:14:34 2007
@@ -64,6 +64,11 @@
 
     protected void undoTo(final UndoableEdit edit) {
         int index = edits.indexOf(edit);
+
+        if (index < 0) { // Fix for HARMONY-2612
+            throw new CannotUndoException();
+        }
+
         for (int i = indexOfNextAdd - 1; i >= index; i--) {
             UndoableEdit e = edits.get(i);
             e.undo();
@@ -73,6 +78,11 @@
 
     protected void redoTo(final UndoableEdit edit) {
         int index = edits.indexOf(edit);
+
+        if (index < 0) { // Fix for HARMONY-2612
+            throw new CannotRedoException();
+        }
+
         for (int i = indexOfNextAdd; i <= index; i++) {
             UndoableEdit e = edits.get(i);
             e.redo();

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/UndoManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/UndoManagerTest.java?view=diff&rev=501905&r1=501904&r2=501905
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/UndoManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/UndoManagerTest.java
Wed Jan 31 09:14:34 2007
@@ -20,9 +20,12 @@
  */
 package javax.swing.undo;
 
+import java.util.Hashtable;
+
 import javax.swing.UIManager;
 import javax.swing.event.UndoableEditEvent;
 
+
 public class UndoManagerTest extends CompoundEditTest {
     protected UndoManager um;
 
@@ -652,6 +655,28 @@
         assertTrue("CannotRedoException was expected", bWasException);
     }
 
+    public void testUndoTo_AIOOB() { // Regression test for HARMONY-2612
+        UndoManager um = new UndoManager();
+        um.addEdit(new AbstractUndoableEdit());
+        try {
+            um.undoTo(null);
+            fail("CannotUndoException should have been thrown");
+        } catch (CannotUndoException e) {
+            // Expected
+        }
+    }
+
+    public void testRedoTo_AIOOB() { // Regression test for HARMONY-2612
+        UndoManager um = new UndoManager();
+        um.addEdit(new AbstractUndoableEdit());
+        try {
+            um.redoTo(null);
+            fail("CannotRedoException should have been thrown");
+        } catch (CannotRedoException e) {
+            // Expected
+        }
+    }
+
     public void testUndoTo() {
         final int editCount = 100;
         TestUndoableEdit[] edits = new TestUndoableEdit[editCount];
@@ -717,4 +742,4 @@
         // 1) edit3.die
         // 2) edit2.die
     }
-}
\ No newline at end of file
+}



Mime
View raw message