Skip to content

Fix InputStreamMonitor.writeNext() wait() not in loop - #2882

Open
robstryker wants to merge 1 commit into
eclipse-platform:masterfrom
robstryker:issue-2881
Open

Fix InputStreamMonitor.writeNext() wait() not in loop#2882
robstryker wants to merge 1 commit into
eclipse-platform:masterfrom
robstryker:issue-2881

Conversation

@robstryker

Copy link
Copy Markdown

Summary

  • Change if (fQueue.isEmpty()) to while (fQueue.isEmpty() && !fClosed) around fLock.wait() in writeNext() to guard against spurious wakeups per JLS 17.2.1
  • Also checks !fClosed to avoid waiting on a closed stream

The existing if guard was added for bug 550834 but doesn't protect against spurious wakeups. Found via SpotBugs static analysis (WA_NOT_IN_LOOP).

Fixes #2881

Test plan

  • Existing InputStreamMonitorTests pass
  • Manual verification: launch a process, write to its stdin, verify output

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   56m 10s ⏱️ - 4m 37s
 4 759 tests ±0   4 737 ✅ ±0   22 💤 ±0  0 ❌ ±0 
12 168 runs  ±0  12 015 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit 016cc7d. ± Comparison against base commit 6b5bed8.

♻️ This comment has been updated with latest results.

@laeubi laeubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Use while loop instead of if to guard Object.wait() against spurious
wakeups per JLS 17.2.1. Also check !fClosed to avoid waiting on a
closed stream.

Fixes eclipse-platform#2881

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

InputStreamMonitor.writeNext() wait() not in loop — vulnerable to spurious wakeups

2 participants