harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496309 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java
Date Mon, 15 Jan 2007 13:24:54 GMT
Author: hindessm
Date: Mon Jan 15 05:24:53 2007
New Revision: 496309

URL: http://svn.apache.org/viewvc?view=rev&rev=496309
Log:
Applying patches from "[#HARMONY-2901] [classlib][swing] several methods of
j.s.plaf.basic.BasicOptionPaneUI throw NPE".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java?view=diff&rev=496309&r1=496308&r2=496309
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicOptionPaneUI.java
Mon Jan 15 05:24:53 2007
@@ -465,7 +465,9 @@
     }
 
     protected void uninstallListeners() {
-        optionPane.removePropertyChangeListener(propertyChangeListener);
+        if (optionPane != null) {
+            optionPane.removePropertyChangeListener(propertyChangeListener);
+        }
         propertyChangeListener = null;
     }
 
@@ -632,6 +634,10 @@
     }
 
     protected Object[] getButtons() {
+        if (optionPane == null) {
+            return null;
+        }
+
         Object[] result = optionPane.getOptions();
         if (!Utilities.isEmptyArray(result)) {
             return result;
@@ -661,6 +667,10 @@
     }
 
     protected int getInitialValueIndex() {
+        if (optionPane == null) {
+            return -1;
+        }
+
         Object[] options = optionPane.getOptions();
         if (Utilities.isEmptyArray(options)) {
             return 0;

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java?view=diff&rev=496309&r1=496308&r2=496309
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicOptionPaneUITest.java
Mon Jan 15 05:24:53 2007
@@ -292,6 +292,12 @@
         assertNull(paneUI.propertyChangeListener);
     }
 
+    // Regression for HARMONY-2901
+    public void testUninstallListenersNull() {
+        assertNull(paneUI.optionPane);
+        paneUI.uninstallListeners(); // no exception is expected
+    }
+
     public void testCreatePropertyChangeListener() {
         assertNotNull(paneUI.createPropertyChangeListener());
     }
@@ -779,6 +785,12 @@
         assertEquals("button ", option3, buttons[2]);
     }
 
+    // Regression for HARMONY-2901
+    public void testGetButtonsNull() {
+        assertNull(paneUI.optionPane);
+        assertNull(paneUI.getButtons());
+    }
+
     public void testGetSizeButtonsToSameWidth() {
         assertTrue(paneUI.getSizeButtonsToSameWidth());
     }
@@ -808,6 +820,12 @@
                 JOptionPane.CLOSED_OPTION, null, null, null);
         paneUI = (BasicOptionPaneUI) optionPane.getUI();
         assertEquals(0, paneUI.getInitialValueIndex());
+    }
+
+    // Regression for HARMONY-2901
+    public void testGetInitialValueIndexNull() throws Exception {
+        assertNull(paneUI.optionPane);
+        assertEquals(-1, paneUI.getInitialValueIndex());
     }
 
     public void testResetInputValue() {



Mime
View raw message