From 2f1fbac695bac43c60d497acd2c9f784f5b52667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Mon, 21 Nov 2022 08:26:05 +0100 Subject: [PATCH] fix race condition Job.run() with IJobChangeEvent.running() #271 The abbreviation check eventQueueThread.isEmpty() can become true before all events processed. Need to have a lock before doing the check. --- .../src/org/eclipse/core/internal/jobs/JobListeners.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobListeners.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobListeners.java index afb80afe5e7..0290791d2f2 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobListeners.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobListeners.java @@ -61,7 +61,7 @@ void waitAndSendEvents(InternalJob job, boolean shouldSend) { boolean send = shouldSend || job.eventQueueLock.isHeldByCurrentThread(); // Synchronize eventQueue to get a stable order of events across Threads. // There is however no guarantee in which Thread the event is delivered. - while (!job.eventQueue.isEmpty()) { + while (true) { if (getJobListenerTimeout() == 0) { // backward compatibility mode for listeners that may deadlock if (send) {