Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5223

[classlib][swing][EIOffice] JComboBox.setEditor throws NPE if editor.getEditorComponent returns null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • Novice

    Description

      JComboBox.setEditor throws the following NPE if editor.getEditorComponent returns null:
      java.lang.NullPointerException
      at javax.swing.plaf.basic.BasicComboBoxUI.configureEditor(BasicComboBoxUI.java:701)
      at javax.swing.plaf.metal.MetalComboBoxUI.configureEditor(MetalComboBoxUI.java:109)
      at javax.swing.plaf.basic.BasicComboBoxUI.addEditor(BasicComboBoxUI.java:411)
      at javax.swing.plaf.basic.BasicComboBoxUI$PropertyChangeHandler.propertyChange(BasicComboBoxUI.java:231)
      at javax.swing.plaf.metal.MetalComboBoxUI$MetalPropertyChangeListener.propertyChange(MetalComboBoxUI.java:82)
      at java.beans.PropertyChangeSupport.doFirePropertyChange(PropertyChangeSupport.java:263)
      at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:54)
      at java.awt.Component.firePropertyChangeImpl(Component.java:1668)
      at java.awt.Component.firePropertyChange(Component.java:1682)
      at javax.swing.JComboBox.setEditor(JComboBox.java:323)
      at ComboBoxEditorTest.main(ComboBoxEditorTest.java:19)

      RI does not throw any exception in this case.

      Here is a test case:
      import java.awt.Component;

      import javax.swing.JComboBox;
      import javax.swing.plaf.basic.BasicComboBoxEditor;

      public class ComboBoxEditorTest {
      public static class NullComboBoxEditor extends BasicComboBoxEditor {
      public NullComboBoxEditor()

      { super(); }

      public Component getEditorComponent()

      { return null; }

      }

      public static void main(String[] args)

      { JComboBox cb = new JComboBox(); cb.setEditor(new NullComboBoxEditor()); System.err.println("OK"); }

      }

      The issue was discovered while running EIOffice on top of Harmony

      Attachments

        Activity

          People

            cap Alexey Petrenko
            cap Alexey Petrenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: