0

Getting below NullpointerException in java library. I suspected that issue is due to updating combo Box values asynchronously in background thread after user logged into application.

Note: this issue is getting in production. Any workaround or fix would greatly appreciated.

     Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
                        at 
            javax.swing.DefaultListCellRenderer.getListCellRendererComponent(Unknown Source)
            at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(Unknown Source)
             at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.getMinimumSize(Unknown Source)
at javax.swing.JComponent.getMinimumSize(Unknown Source)
                        at java.awt.FlowLayout.minimumLayoutSize(Unknown Source)
                        at java.awt.Container.minimumSize(Unknown Source)
                        at java.awt.Container.getMinimumSize(Unknown Source)
                        at javax.swing.JComponent.getMinimumSize(Unknown Source)
                        at javax.swing.BoxLayout.checkRequests(Unknown Source)
                        at javax.swing.BoxLayout.preferredLayoutSize(Unknown Source)
                        at java.awt.Container.preferredSize(Unknown Source)
                        at java.awt.Container.getPreferredSize(Unknown Source)
                        at javax.swing.JComponent.getPreferredSize(Unknown Source)
                        at java.awt.FlowLayout.preferredLayoutSize(Unknown Source)
                        at java.awt.Container.preferredSize(Unknown Source)
                        at java.awt.Container.getPreferredSize(Unknown Source)
                        at javax.swing.JComponent.getPreferredSize(Unknown Source)
                        at java.awt.BorderLayout.layoutContainer(Unknown Source)
                        at java.awt.Container.layout(Unknown Source)
                        at java.awt.Container.doLayout(Unknown Source)
                        at java.awt.Container.validateTree(Unknown Source)
                        at java.awt.Container.validateTree(Unknown Source)
                        at java.awt.Container.validateTree(Unknown Source)
                        at java.awt.Container.validateTree(Unknown Source)
                        at java.awt.Container.validateTree(Unknown Source)
                        at java.awt.Container.validate(Unknown Source)
                        at javax.swing.RepaintManager$3.run(Unknown Source)
                        at javax.swing.RepaintManager$3.run(Unknown Source)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
                rivilege(Unknown Source)
                        at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
                        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
                        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
                        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
                        at java.awt.EventQueue.access$500(Unknown Source)
                        at java.awt.EventQueue$3.run(Unknown Source)
                        at java.awt.EventQueue$3.run(Unknown Source)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
                rivilege(Unknown Source)       
  • 2
    1) Be sure that the application is started on the Swing event thread, 2) Also make changes to the comb box's model only on the event thread. 3) try to create a [mcve] that causes the error, and post this. – Hovercraft Full Of Eels Feb 08 '17 at 17:50
  • 1. Yes, app is started in Swing event(java.awt.EventQueue.invokeLater(..)) 2)Yes, combo box model is being updated in EventQueue.invokeLater(new Runnable(..)) 3) this will take time to identify the parts of app to make precise and reproducable, will try it – dhorrairaajj Feb 08 '17 at 18:04
  • At the very least, add the code which updates the ComboBoxModel to your question. If any code alters or prepares the data prior to the EventQueue.invokeLater call, include that code as well. – VGR Feb 08 '17 at 19:10
  • Finally, I found that the issue is with having the both action listener and item change listener for the same searchable combobox was the root cause. I have removed listeners as temporary solution and customers got effected. – dhorrairaajj Feb 13 '17 at 17:04

0 Answers0