harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495676 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/Choice.java test/api/java/common/java/awt/ChoiceTest.java
Date Fri, 12 Jan 2007 18:17:30 GMT
Author: hindessm
Date: Fri Jan 12 10:17:28 2007
New Revision: 495676

URL: http://svn.apache.org/viewvc?view=rev&rev=495676
Log:
Applied patches from "[#HARMONY-2468] [classlib][awt]
java.awt.Choice.insert(null, 0) does not throw NPE while RI throws it".

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ChoiceTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java?view=diff&rev=495676&r1=495675&r2=495676
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Choice.java
Fri Jan 12 10:17:28 2007
@@ -342,12 +342,18 @@
     }
 
     public void insert(String item, int index) {
+        if (index < 0) {
+            // awt.105=index less than zero
+            throw new IllegalArgumentException(Messages.getString("awt.105")); //$NON-NLS-1$
+        }
+        
+        if (item == null) {
+            // awt.105='item' parameter is null
+            throw new NullPointerException(Messages.getString("awt.01", "item")); //$NON-NLS-1$
//$NON-NLS-2$
+        }
+        
         toolkit.lockAWT();
         try {
-            if (index < 0) {
-                // awt.105=index less than zero
-                throw new IllegalArgumentException(Messages.getString("awt.105")); //$NON-NLS-1$
-            }
             int idx = Math.min(items.size(), index);
             if (items.size() == 0) {
                 selectedIndex = 0;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ChoiceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ChoiceTest.java?view=diff&rev=495676&r1=495675&r2=495676
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ChoiceTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ChoiceTest.java
Fri Jan 12 10:17:28 2007
@@ -213,6 +213,14 @@
         choice.insert(item = "end", choice.getItemCount() + 100);
         assertSame(item, choice.getItem(choice.getItemCount() - 1));
         assertEquals(2, choice.getSelectedIndex());
+        
+        // Regression test for HARMONY-2468
+        try {
+            new Choice().insert(null, 0);
+            fail("NullPointerException expected"); //$NON-NLS-1$
+        } catch (NullPointerException ex) {
+            // expected
+        }
     }
 
     public final void testGetSelectedObjects() {



Mime
View raw message