In InputStreamMonitor.writeNext(), the fLock.wait() call at line 189 is guarded by an if check:
synchronized(fLock) {
// Queue could receive more input between last empty check and
// lock acquire. See https://bugs.eclipse.org/550834
if (fQueue.isEmpty()) {
fLock.wait();
}
}
Per the Java specification, Object.wait() can return spuriously — without a corresponding notify()/notifyAll(). The standard pattern is to use a while loop instead of if:
synchronized(fLock) {
while (fQueue.isEmpty() && !fClosed) {
fLock.wait();
}
}
This ensures the condition is rechecked after any wakeup. The !fClosed guard also avoids waiting forever if the stream was closed while waiting.
Found via SpotBugs static analysis (WA_NOT_IN_LOOP).
In
InputStreamMonitor.writeNext(), thefLock.wait()call at line 189 is guarded by anifcheck:Per the Java specification,
Object.wait()can return spuriously — without a correspondingnotify()/notifyAll(). The standard pattern is to use awhileloop instead ofif:This ensures the condition is rechecked after any wakeup. The
!fClosedguard also avoids waiting forever if the stream was closed while waiting.Found via SpotBugs static analysis (WA_NOT_IN_LOOP).