From e9463136f2ed988fa09ff2ca4fff73682436d804 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 6 Jul 2010 22:17:55 +0000 Subject: [PATCH] follow up to rev.31906. I think this was breaking the atomicity. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@32528 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Executor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index bfdc7482dc..2bf1cbefb2 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -102,10 +102,12 @@ public class Executor extends Thread implements ModelObject { Queue.Item queueItem; Queue.Task task; try { - queueItem = grabJob(); - task = queueItem.task; - startTime = System.currentTimeMillis(); - executable = task.createExecutable(); + synchronized (queue) { + queueItem = grabJob(); + task = queueItem.task; + startTime = System.currentTimeMillis(); + executable = task.createExecutable(); + } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Executor throw an exception unexpectedly", e); continue;