<Swing Dev> [9] Fix for JDK-8041909 : Uncaught exceptions in JComboBox listeners cause listener not to receive events

Ajit Ghaisas ajit.ghaisas at oracle.com
Wed Jun 15 07:05:35 UTC 2016


Hi,

Bug :
    https://bugs.openjdk.java.net/browse/JDK-8041909

Issue :
    Uncaught exceptions in JComboBox listeners cause listener not to receive events.
    If an uncaught exception is thrown inside an action listener for a JComboBox, that action listener will no longer receive action events. 
    Note that if an uncaught exception is thrown inside the action listener for a JButton for example, the listener will still receive subsequent action events.

Root Cause :
    fireActionEvent() method in JComboBox class has a boolean guard (namely firingActionEvent) to ensure that an infinite loop is not created.
    This guard is not reset if any exception occurs in actionPerformed() method.
    This results in permanent breaking of subsequent action listener invocations of JComboBox.

Fix :
    The boolean guard (namely firingActionEvent) is reset in finally block. 
    This results in firingActionEvent being set to false at the end of fireActionEvent() method even in case of exception in actionPerformed() method.

Webrev :
    http://cr.openjdk.java.net/~aghaisas/8041909/webrev.00/

Request you to review.

Regards,
Ajit



More information about the swing-dev mailing list