Skip to content

Fixed ConcurrentModificationException in getScreenLines - #139

Merged
oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/concurrent-modification-get-screen-lines
May 23, 2026
Merged

oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/concurrent-modification-get-screen-lines

Conversation

@oleg68

@oleg68 oleg68 commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Acquired TerminalTextBuffer.tryLock() before reading the screen buffer in getScreenLines() (ClaudeSessionTab.java:1471)

Root cause

The EDT screen-poll timer called getScreenLines() which read JediTerm's TerminalTextBuffer without holding the buffer lock. The PTY thread writes to the same buffer concurrently, causing ConcurrentModificationException inside TerminalLine.getText() → LinesBuffer.getLineTexts().

tryLock() (non-blocking) is used instead of lock() so the EDT timer never blocks waiting for a PTY write — it returns an empty list and retries on the next tick.

Test plan

  • mvn test — 858 tests pass
  • Start a session, let it run — no ConcurrentModificationException in messages.log

The EDT screen-poll timer read JediTerm's TerminalTextBuffer without
holding the buffer lock while the PTY thread was writing to it,
causing ConcurrentModificationException inside TerminalLine.getText().

Fixed by acquiring TerminalTextBuffer.tryLock() before reading the
screen buffer. tryLock() (non-blocking) is used instead of lock() so
the EDT timer never blocks waiting for a PTY write to finish — it
simply returns an empty list and retries on the next tick.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@oleg68
oleg68 merged commit d26888e into nbplugins:main May 23, 2026
3 checks passed
@oleg68
oleg68 deleted the bugfix/concurrent-modification-get-screen-lines branch May 23, 2026 16:18
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.

1 participant