Commit 38317f9
Fix race condition in AbstractReconciler.reset() causing test timeouts
Fixes #2708
The test FastAbstractReconcilerTest#testReplacingDocumentWhenClean() was
intermittently failing with a 5-second timeout. The test would wait at a
barrier expecting the reconciler to process, but the reconciler thread
never executed the process() method.
Root Cause:
-----------
The race condition occurred in the BackgroundWorker.reset() method due to
improper ordering of operations with two separate locks (the BackgroundWorker
instance lock and the fDirtyRegionQueue lock):
Old sequence:
1. Set fIsDirty=true and fReset=true (under BackgroundWorker lock)
2. Notify fDirtyRegionQueue
3. Call informNotFinished() which calls aboutToWork()
4. aboutToWork() may call signalWaitForFinish() which sets waitFinish=true
The problem: The reconciler thread could wake up from the notification in
step 2 BEFORE waitFinish was set to true in step 4, causing it to delay
again for the full fDelay period instead of processing immediately.
Additionally, due to the two separate locks, the reconciler thread could
check isDirty() and see a stale value before fIsDirty was set.
The Fix:
--------
Move the informNotFinished() call to AFTER setting fIsDirty/fReset but
BEFORE notifying the queue:
New sequence:
1. Set fIsDirty=true and fReset=true (under BackgroundWorker lock)
2. Call informNotFinished() → aboutToWork() → signalWaitForFinish()
3. signalWaitForFinish() sets waitFinish=true and notifies queue
4. Final notifyAll() on queue (redundant but harmless)
This ensures that when the reconciler thread wakes up, both fIsDirty and
waitFinish are already set to their correct values, eliminating the race.
Testing:
--------
- Compiled successfully with mvn clean compile -Pbuild-individual-bundles
- The fix preserves the existing behavior while ensuring proper synchronization
- FastAbstractReconcilerTest.testReplacingDocumentWhenClean should no longer timeout
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent ce17c9e commit 38317f9
File tree
1 file changed
+2
-2
lines changed- bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler
1 file changed
+2
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
0 commit comments