assertj / assertj-swing

Fluent assertions for Swing apps
Other
108 stars 52 forks source link

CheckThreadViolationRepaintManager gives false positives when used with SwingWorker #223

Closed lbalazscs closed 5 years ago

lbalazscs commented 6 years ago

org.assertj.swing.edt.CheckThreadViolationRepaintManager works by inspecting the stack trace of repaint calls which are not on the EDT, and if it sees a swing package before the repaint call, it assumes that Swing called it. repaint() in itself can be called from any thread, but the assumption is that if a swing code calls repaint() outside the EDT, something else in Swing was manipulated outside the EDT.

Calling repaint() on the background thread of a SwingWorker is OK (as repaint() in itself is thread-safe) , but the problem is that this leaves a "javax.swing" in the stack trace, and confuses CheckThreadViolationRepaintManager . Note that newer versions of the "swinghelper" (from where this code is coming), do take SwingWorker into account, see for example https://github.com/floscher/swinghelper/blob/master/src/java/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java

debugger

croesch commented 6 years ago

Hi @lbalazscs

Thanks for submitting this issue! You sound like you took a good effort in analyzing this issue, could you also come up with a pull request that solves that issue? Looking forward reviewing and merging it! :)

best regards, Christian

lbalazscs commented 6 years ago

OK, I will send a pull request in a few days.

croesch commented 5 years ago

Released in 3.9.2. Thanks for your help!