Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,27 @@ public void suspendCallerWhileDirty() {
*/
public void reset() {

reconcilerReset();

if (fDelay > 0) {

synchronized (this) {
fIsDirty= true;
fReset= true;
}
synchronized (fDirtyRegionQueue) {
fDirtyRegionQueue.notifyAll(); // wake up wait(fDelay);
}

} else {

synchronized (this) {
fIsDirty= true;
}

synchronized (fDirtyRegionQueue) {
fDirtyRegionQueue.notifyAll();
}
}

informNotFinished();
reconcilerReset();

synchronized (fDirtyRegionQueue) {
fDirtyRegionQueue.notifyAll();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jface.text.tests
Bundle-Version: 3.14.0.qualifier
Bundle-Version: 3.14.100.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jface.text.tests.contentassist.IncrementalAsyncContentAssistTests;
import org.eclipse.jface.text.tests.reconciler.AbstractReconcilerTest;
import org.eclipse.jface.text.tests.reconciler.FastAbstractReconcilerTest;
import org.eclipse.jface.text.tests.reconciler.ReconcilerResetOrderingTest;
import org.eclipse.jface.text.tests.rules.FastPartitionerTest;
import org.eclipse.jface.text.tests.rules.FastPartitionerZeroLengthTest;
import org.eclipse.jface.text.tests.rules.ScannerColumnTest;
Expand Down Expand Up @@ -61,6 +62,7 @@

AbstractReconcilerTest.class,
FastAbstractReconcilerTest.class,
ReconcilerResetOrderingTest.class,

FastPartitionerZeroLengthTest.class,
FastPartitionerTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ protected void aboutToBeReconciled() {
}
@Override
protected void reconcilerReset() {
AbstractReconcilerTest.this.beforeReconcilerResetLogged();
fCallLog.add("reconcilerReset");
}
@Override
Expand Down Expand Up @@ -202,6 +203,10 @@ void aboutToWork(@SuppressWarnings("unused") AbstractReconciler reconciler) {
// nothing
}

void beforeReconcilerResetLogged() {
// hook for subclasses to widen race window
}

@AfterEach
public void tearDown() throws Exception {
fBarrier.shutdown();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.jface.text.tests.reconciler;

import org.eclipse.jface.text.reconciler.AbstractReconciler;

/**
* Regression test for the race condition in
* {@link AbstractReconciler#install BackgroundWorker.reset()} where
* {@code reconcilerReset()} could be called after the background thread was
* already notified, allowing {@code process()} to run before the reset hook.
* <p>
* This test widens the race window by introducing a 50ms delay before logging
* {@code reconcilerReset}. Without the fix (reconcilerReset called before queue
* notification), the background thread is already awake during the delay and
* reaches {@code process()} first, causing {@code testReplacingDocumentWhenClean}
* to deterministically fail.
* </p>
*
* @see <a href="https://github.com/eclipse-platform/eclipse.platform.ui/issues/2708">Issue 2708</a>
*/
public class ReconcilerResetOrderingTest extends FastAbstractReconcilerTest {

@Override
void beforeReconcilerResetLogged() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
Loading