Skip to content

Commit f82850a

Browse files
committed
Do not block; show more job info
1 parent fa1f135 commit f82850a

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

plugins/com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/project/ProjectUtils.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Collections;
3131
import java.util.Enumeration;
3232
import java.util.HashSet;
33+
import java.util.Iterator;
3334
import java.util.LinkedHashSet;
3435
import java.util.List;
3536
import java.util.Set;
@@ -206,10 +207,8 @@ public static void waitForProjects(Runnable delayTactic, IProject... projects) {
206207
// wait a little bit to give the builders a chance
207208
delayTactic.run();
208209

209-
// wait for any previously-identified build jobs
210-
for (Job job : jobs) {
211-
job.join();
212-
}
210+
// NB: don't join jobs: see #1529
211+
// for details: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/pull/1529
213212

214213
// identify any pending build-related jobs
215214
jobs = findPendingBuildJobs(projects);
@@ -232,7 +231,7 @@ public static void waitForProjects(Runnable delayTactic, IProject... projects) {
232231
dumpJobsState();
233232
}
234233
} while (!jobs.isEmpty() || buildErrorsChanging);
235-
} catch (CoreException | InterruptedException ex) {
234+
} catch (CoreException ex) {
236235
throw new RuntimeException(ex);
237236
}
238237
}
@@ -266,8 +265,8 @@ private static void dumpJobsState() {
266265
}
267266
Object blockingJob = null;
268267
try {
269-
blockingJob =
270-
ReflectionUtil.invoke(Job.getJobManager(), "findBlockingJob", InternalJob.class, job);
268+
blockingJob = ReflectionUtil.invoke(Job.getJobManager(), "findBlockingJob",
269+
new Class<?>[] {InternalJob.class}, InternalJob.class, job);
271270
} catch (Exception ex) {
272271
System.err.println("Unable to fetch blocking-job: " + ex);
273272
}
@@ -294,6 +293,13 @@ private static Collection<Job> findPendingBuildJobs(IProject... projects) {
294293
Collections.addAll(jobs, jobManager.find(
295294
project.getName() + ValidatorManager.VALIDATOR_JOB_FAMILY));
296295
}
296+
// remove sleeping jobs
297+
for (Iterator<Job> iter = jobs.iterator(); iter.hasNext();) {
298+
Job job = iter.next();
299+
if (job.getState() == Job.SLEEPING) {
300+
iter.remove();
301+
}
302+
}
297303
return jobs;
298304
}
299305

plugins/com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/reflection/ReflectionUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public static <T> T invoke(Object object, String methodName, Class<T> returnType
4242
for (int i = 0; i < parameters.length; i++) {
4343
parameterTypes[i] = parameters[i] == null ? Object.class : parameters[i].getClass();
4444
}
45+
return invoke(object, methodName, parameterTypes, returnType, parameters);
46+
}
47+
48+
/** Invoke a method. */
49+
public static <T> T invoke(Object object, String methodName, Class<?>[] parameterTypes,
50+
Class<T> returnType, Object... parameters) throws NoSuchMethodException, SecurityException,
51+
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
4552
Method method = object.getClass().getDeclaredMethod(methodName, parameterTypes);
4653
method.setAccessible(true);
4754
return returnType.cast(method.invoke(object, parameters));

0 commit comments

Comments
 (0)