From cd92a6ba3d0f33f74939f5e599b43c2348ee049d Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 28 Jun 2007 05:40:13 +0000 Subject: [PATCH] return an indicator value. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3586 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Queue.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index a2614ed948..cf95959ced 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -198,17 +198,24 @@ public class Queue { return true; } - public synchronized void cancel( AbstractProject p ) { + /** + * Cancels the item in the queue. + * + * @return + * true if the project was indeed in the queue and was removed. + * false if this was no-op. + */ + public synchronized boolean cancel( AbstractProject p ) { LOGGER.fine("Cancelling "+p.getName()); for (Iterator itr = queue.iterator(); itr.hasNext();) { Item item = (Item) itr.next(); if(item.task ==p) { itr.remove(); - return; + return true; } } - blockedProjects.remove(p); - buildables.remove(p); + // use bitwise-OR to make sure that both branches get evaluated all the time + return blockedProjects.remove(p)|buildables.remove(p); } public synchronized boolean isEmpty() { -- GitLab