Skip to content

Fix permanent UI freeze from off-EDT JsonResponseView.setEditorContent - #901

Open
adityaanikam wants to merge 1 commit into
SmartBear:nextfrom
adityaanikam:fix-jsonresponseview-edt-deadlock-898
Open

Fix permanent UI freeze from off-EDT JsonResponseView.setEditorContent#901
adityaanikam wants to merge 1 commit into
SmartBear:nextfrom
adityaanikam:fix-jsonresponseview-edt-deadlock-898

Conversation

@adityaanikam

Copy link
Copy Markdown

Fixes #898

JsonResponseView.propertyChange called setEditorContent directly on the RESPONSE_PROPERTY change, which fires from the request submit worker thread, not the EDT. setEditorContent mutates the RSyntaxDocument via JTextComponent.setText, which violates Swing's single-thread rule.

This produces a classic AB-BA deadlock when a response lands while the EDT is mid layout pass: the worker thread holds the document write lock and blocks trying to acquire the AWTTreeLock (via RUndoManager updating action enablement), while the EDT already holds the AWTTreeLock during validate and blocks waiting for the same document's read lock. Neither thread can proceed, and only killing the process recovers, exactly as documented in the issue with a full thread dump.

Deferred the setEditorContent call to SwingUtilities.invokeLater so the document is only ever mutated on the EDT, removing the cross-thread lock contention entirely. The updatingRequest reentrancy guard is left exactly where it was, set synchronously on the calling thread around scheduling the update, not around running it.

Verified by tracing the exact lock chain in the issue thread dump against current source and by compiling soapui/src/main/java cleanly with mvn compile. This is a Swing threading fix, not something a unit test can reasonably exercise given the race is timing dependent.

JsonResponseView.propertyChange called setEditorContent directly on the RESPONSE_PROPERTY change, which fires from the request submit worker thread, not the EDT. setEditorContent mutates the RSyntaxDocument via JTextComponent.setText, which violates Swing's single-thread rule.

This produces a classic AB-BA deadlock when a response lands while the EDT is mid layout pass: the worker thread holds the document write lock and blocks trying to acquire the AWTTreeLock (via RUndoManager updating action enablement), while the EDT already holds the AWTTreeLock during validate and blocks waiting for the same document's read lock. Neither thread can proceed, and only killing the process recovers, as documented in the issue with a full thread dump.

Deferred the setEditorContent call to SwingUtilities.invokeLater so the document is only ever mutated on the EDT, removing the cross-thread lock contention entirely. The updatingRequest reentrancy guard is left exactly where it was, set synchronously on the calling thread around scheduling the update, not around running it.

Verified by tracing the exact lock chain in the issue's thread dump against current source and by compiling soapui/src/main/java cleanly with mvn compile. This is a Swing threading fix, not something a unit test can reasonably exercise given the race is timing dependent.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI deadlock (permanent freeze) when JSON response view updates from submit thread — JsonResponseView.setEditorContent called off the EDT

1 participant