From 3fc44fdfddce644166d33b6cb4d63bc6c8689c63 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 21 Oct 2009 15:27:56 +0000 Subject: [PATCH] removed pointless empty check that doesn't affect the execution. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22984 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Queue.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index d2ba96cc78..254a237d0c 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -416,10 +416,11 @@ public class Queue extends ResourceController implements Saveable { * That said, one can still look at {@link WaitingItem#future}, {@link WaitingItem#id}, etc. */ private synchronized WaitingItem scheduleInternal(Task p, int quietPeriod, List actions) { - WaitingItem added=null; + WaitingItem added; Calendar due = new GregorianCalendar(); due.add(Calendar.SECOND, quietPeriod); + // Do we already have this task in the queue? Because if so, we won't schedule a new one. List duplicatesInQueue = new ArrayList(); for(Item item : getItems(p)) { boolean shouldScheduleItem = false; @@ -433,13 +434,15 @@ public class Queue extends ResourceController implements Saveable { duplicatesInQueue.add(item); } } - if (duplicatesInQueue.size() == 0) { + if (duplicatesInQueue.isEmpty()) { LOGGER.fine(p.getFullDisplayName() + " added to queue"); // put the item in the queue waitingList.add(added=new WaitingItem(due,p,actions)); } else { // the requested build is already queued, so will not be added + added = null; + List waitingDuplicates = new ArrayList(); for(Item item : duplicatesInQueue) { for(FoldableAction a : Util.filter(actions,FoldableAction.class)) { @@ -448,11 +451,6 @@ public class Queue extends ResourceController implements Saveable { if ((item instanceof WaitingItem)) waitingDuplicates.add((WaitingItem)item); } - if(duplicatesInQueue.isEmpty()) { - // all duplicates in the queue are already in the blocked or - // buildable stage no need to requeue - return null; - } // TODO: avoid calling scheduleMaintenance() if none of the waiting items // actually change for(WaitingItem wi : waitingDuplicates) { -- GitLab