kirill-grouchnikov / substance

A modern and high-performant Swing look-and-feel library
163 stars 110 forks source link

NullPointerException in RootPaneDefaultButtonTracker #44

Closed enwired closed 7 years ago

enwired commented 7 years ago

There is a possibility of a rare NullPointerException in RootPaneDefaultButtonTracker caused by what seems to me a simple logic error.

Basically, these two lines in RootPaneDefaultButtonTracker should be reversed:

tracker.startTimer();
trackers.put(jButton, tracker);

You should not start the timer loop before the tracker has been associated with the button in the map. Otherwise, this later code can produce a NullPointerException:

RootPaneDefaultButtonTracker tracker = trackers.get(jButton);
tracker.stopTimer();

An alternative fix is to put a check for tracker==null before calling tracker.stopTimer()

The bug is very, very rare, but I have seen it happen. I found and fixed this issue on a forked version: https://github.com/Insubstantial/insubstantial/issues/137

A stack trace is included there. The root cause still exists in Substance 7.1.

kirill-grouchnikov commented 7 years ago

Thanks Ed. I've added the fix locally. Will wait a couple more days to see if there's anything else that would be worth putting into a 7.1.01 respin and then push the update.

enwired commented 7 years ago

Thanks. And I'm in no rush. My project using Substance 7 won't have another release for 6 months or more.