Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

NPE on Combo Box Item State Changed #4

Description

@mglazer

Here's a stack trace I get quite a bit with the latest version

ERROR [AWT-EventQueue-1] com.palantir.ptoss.cinch.swing.BoundSelection - could not invoke JComboBox binding
java.lang.NullPointerException
    at com.palantir.ptoss.cinch.swing.BoundSelection$Wiring$3.itemStateChanged(BoundSelection.java:190)
    at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1205)
    at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1253)
    at javax.swing.JComboBox.contentsChanged(JComboBox.java:1309)
    at javax.swing.JComboBox.intervalRemoved(JComboBox.java:1331)
    at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:161)
    at javax.swing.DefaultComboBoxModel.removeAllElements(DefaultComboBoxModel.java:169)
    at javax.swing.JComboBox.removeAllItems(JComboBox.java:751)

It occurs because I call remove on an empty combo box, and combo.getSelectedItem() returns null:

Object current = mutator.get();
Object newValue = combo.getSelectedItem();
if (newValue.equals(nullValue)) {

This should be changed to:

Objects.equals(newValue, nullValue)

Or something similar.

Really minor, but the error message clogs up my console.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions