harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r499810 - in /harmony/enhanced/classlib/trunk/modules: awt/src/main/java/common/java/awt/ awt/src/test/api/java/common/java/awt/ swing/src/main/java/common/javax/swing/plaf/basic/ swing/src/main/java/common/javax/swing/plaf/metal/
Date Thu, 25 Jan 2007 15:01:35 GMT
Author: ayza
Date: Thu Jan 25 07:01:34 2007
New Revision: 499810

URL: http://svn.apache.org/viewvc?view=rev&rev=499810
Log:
Applying the patch from HARMONY-2019 ([classlib][awt] Container.remove(null) expected NPE)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ContainerRTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java?view=diff&rev=499810&r1=499809&r2=499810
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java
Thu Jan 25 07:01:34 2007
@@ -277,6 +277,10 @@
     public void remove(Component comp) {
         toolkit.lockAWT();
         try {
+            if (comp == null) {
+                throw new NullPointerException();
+            }
+
             try {
                 remove(children.indexOf(comp));
             } catch (ArrayIndexOutOfBoundsException e) {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ContainerRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ContainerRTest.java?view=diff&rev=499810&r1=499809&r2=499810
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ContainerRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ContainerRTest.java
Thu Jan 25 07:01:34 2007
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Vladimir Ivanov
- * @version $Revision$
- */
 package java.awt;
 
 
@@ -26,6 +22,15 @@
 
 public class ContainerRTest extends TestCase {
 
+    public final void testRemoveComponent() {
+        // Regression test for HARMONY-1476
+        try {
+            new Container().remove((Component) null);
+            fail("NPE was not thrown");
+        } catch (NullPointerException ex) {
+            // passed
+        }
+    }
 
     public final void testSetFocusTraversalKeys() {
         try {
@@ -63,17 +68,4 @@
             // PASSED            
         }
     }
-
-//    public final void testRemoveComponent() {
-//        Button b = new Button();
-//        boolean npeThrown = false;
-//        Container c = new Container();
-//        c.remove(b); // no exception is thrown
-//        try {
-//            c.remove(b = null);
-//        } catch (NullPointerException npe) {
-//            npeThrown = true;
-//        }        
-//        assertTrue("remove(null) throws NPE", npeThrown);
-//    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java?view=diff&rev=499810&r1=499809&r2=499810
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java
Thu Jan 25 07:01:34 2007
@@ -308,7 +308,10 @@
     }
 
     protected void replaceEditor(final JComponent oldEditor, final JComponent newEditor)
{
-        spinner.remove(oldEditor);
+        if (oldEditor != null) {
+            spinner.remove(oldEditor);
+        }
+
         editor = newEditor;
 
         if (!paintEditorBorder && editor instanceof DefaultEditor) {
@@ -324,4 +327,4 @@
     private void uninstallKeyboardActions() {
         BasicSpinnerKeyboardActions.uninstallKeyboardActions(spinner);
     }
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java?view=diff&rev=499810&r1=499809&r2=499810
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
Thu Jan 25 07:01:34 2007
@@ -849,7 +849,12 @@
                         fileNameField.setText(fileToText(getFileChooser().getCurrentDirectory()));
                     }
                 } else if (JFileChooser.ACCESSORY_CHANGED_PROPERTY.equals(changedProperty))
{
-                    getAccessoryPanel().remove((JComponent)event.getOldValue());
+		    final JComponent old = (JComponent) event.getOldValue();
+                    		    
+                    if (old != null) {
+                        getAccessoryPanel().remove(old);
+                    }
+
                     getAccessoryPanel().add((JComponent)event.getNewValue());
                 } else if (StringConstants.TRANSFER_HANDLER_PROPERTY_NAME.equals(changedProperty))
{
                     list.setTransferHandler((TransferHandler)event.getNewValue());
@@ -1533,4 +1538,4 @@
         }
     }
     
-}
\ No newline at end of file
+}



Mime
View raw message