Skip to content

Commit 6d68774

Browse files
iloveeclipsenoopur2507
authored andcommitted
Avoid waiting for reconciler job
After eclipse-platform/eclipse.platform.ui#3025 every opened editor means there will be a reconciler job running, which is not what we do NOT want to wait for. AbstractReconciler.class is the family object we can check for, so add that family to the list of excluded jobs we don't care. Added getUsualJobFamiliesToIgnore() and changed waitForJobs() to use that by default if nothing else is given. Fixes #721
1 parent 1b10eee commit 6d68774

File tree

1 file changed

+26
-1
lines changed
  • org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests

1 file changed

+26
-1
lines changed

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/TestUtil.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
import org.eclipse.debug.core.DebugPlugin;
3232
import org.eclipse.debug.core.ILaunch;
3333
import org.eclipse.debug.core.ILaunchManager;
34+
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
3435
import org.eclipse.jdt.debug.testplugin.JavaTestPlugin;
36+
import org.eclipse.jface.text.reconciler.AbstractReconciler;
3537
import org.eclipse.swt.widgets.Display;
3638
import org.junit.Assert;
3739

@@ -110,6 +112,8 @@ public static void runEventLoop() {
110112
/**
111113
* Utility for waiting until the execution of jobs of any family has finished or timeout is reached. If no jobs are running, the method waits
112114
* given minimum wait time. While this method is waiting for jobs, UI events are processed.
115+
* <p>
116+
* <b>Note:</b> This method does not wait for jobs that belong to the families specified in {@link #getUsualJobFamiliesToIgnore()}.
113117
*
114118
* @param owner
115119
* name of the caller which will be logged as prefix if the wait times out
@@ -120,7 +124,7 @@ public static void runEventLoop() {
120124
* @return true if the method timed out, false if all the jobs terminated before the timeout
121125
*/
122126
public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs) {
123-
return waitForJobs(owner, minTimeMs, maxTimeMs, (Object[]) null);
127+
return waitForJobs(owner, minTimeMs, maxTimeMs, getUsualJobFamiliesToIgnore());
124128
}
125129

126130
/**
@@ -146,6 +150,15 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
146150
if (maxTimeMs < minTimeMs) {
147151
throw new IllegalArgumentException("Max time is smaller as min time!");
148152
}
153+
// Not so nice workaround for https://github.com/eclipse-jdt/eclipse.jdt.debug/issues/721
154+
// After https://github.com/eclipse-platform/eclipse.platform.ui/pull/3025 every opened editor
155+
// means there will be a reconciler job running, which is not what we do NOT want to wait for.
156+
// AbstractReconciler.class is the family object we can check for.
157+
if (excludedFamilies == null) {
158+
excludedFamilies = new Object[] { AbstractReconciler.class };
159+
} else if (excludedFamilies.length == 1 && excludedFamilies[0] == ProcessConsole.class) {
160+
excludedFamilies = getUsualJobFamiliesToIgnore();
161+
}
149162
wakeUpSleepingJobs(jobFamily);
150163
final long startNanos = System.nanoTime();
151164
while (System.nanoTime() - startNanos < minTimeMs * 1_000_000L) {
@@ -185,6 +198,18 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
185198
return false;
186199
}
187200

201+
/**
202+
* Returns a list of job families that are usually ignored in tests.
203+
* <p>
204+
* This is used to avoid waiting for jobs that are not relevant to the test.
205+
* </p>
206+
*
207+
* @return an array of job family classes to ignore
208+
*/
209+
public static Object[] getUsualJobFamiliesToIgnore() {
210+
return new Object[] { ProcessConsole.class, AbstractReconciler.class };
211+
}
212+
188213
private static void wakeUpSleepingJobs(Object family) {
189214
List<Job> sleepingJobs = getSleepingJobs(family);
190215
for (Job job : sleepingJobs) {

0 commit comments

Comments
 (0)