Source:
public CauseOfBlockage canRun(Queue.Item item) { if (!(item.task instanceof Job)) { logger.debug("Not an abstract project: {}", item.task); return null; } GerritCause cause = getGerritCause(item); if (cause == null) { logger.debug("Not Gerrit cause"); return null; } GerritTriggeredEvent event = cause.getEvent(); if (event == null) { logger.debug("Does not contain an event"); return null; } if (item.isBuildable()) { logger.debug("Item is already buildable"); return null; } Job p = (Job)item.task; GerritTrigger trigger = GerritTrigger.getTrigger(p); if (trigger == null) { logger.debug("Project does not contain a trigger"); return null; } List<Job> dependencies = getProjectsFromString(trigger.getDependencyJobsNames(), (Item)p); if ((dependencies == null) || (dependencies.size() == 0)) { logger.debug("No dependencies on project: {}", p); return null; } long inQueueSince = item.getInQueueSince(); if (System.currentTimeMillis() - inQueueSince < TimeUnit.SECONDS .toMillis(GerritDefaultValues.DEFAULT_BUILD_SCHEDULE_DELAY)) { logger.debug("We need to wait to ensure dependent jobs are in queue", event); return new BecauseWaitingToEnsureOtherJobsAreInQueue(); } if (currentlyTriggeringEvents.contains(event)) { logger.debug("We need to wait while is being triggered", event); return new BecauseWaitingForOtherProjectsToTrigger(); } List<Job> blockingProjects = getBlockingDependencyProjects(dependencies, event); if (blockingProjects.size() > 0) { return new BecauseDependentBuildIsBuilding(blockingProjects); } else { logger.info("No active dependencies on project: , it will now build", p); return null; } }

Target:
public CauseOfBlockage canRun(Queue.Item item) { if (!(item.task instanceof Job)) { logger.debug("Not an Job instance: {}", item.task); return null; } GerritCause cause = getGerritCause(item); if (cause == null) { logger.debug("Not Gerrit cause"); return null; } GerritTriggeredEvent event = cause.getEvent(); if (event == null) { logger.debug("Does not contain an event"); return null; } if (item.isBuildable()) { logger.debug("Item is already buildable"); return null; } Job p = (Job)item.task; GerritTrigger trigger = GerritTrigger.getTrigger(p); if (trigger == null) { logger.debug("Project does not contain a trigger"); return null; } List<Job> dependencies = getProjectsFromString(trigger.getDependencyJobsNames(), (Item)p); if ((dependencies == null) || (dependencies.size() == 0)) { logger.debug("No dependencies on project: {}", p); return null; } long inQueueSince = item.getInQueueSince(); if (System.currentTimeMillis() - inQueueSince < TimeUnit.SECONDS .toMillis(GerritDefaultValues.DEFAULT_BUILD_SCHEDULE_DELAY)) { logger.debug("We need to wait to ensure dependent jobs are in queue", event); return new BecauseWaitingToEnsureOtherJobsAreInQueue(); } if (currentlyTriggeringEvents.contains(event)) { logger.debug("We need to wait while is being triggered", event); return new BecauseWaitingForOtherProjectsToTrigger(); } List<Job> blockingProjects = getBlockingDependencyProjects(dependencies, event); if (blockingProjects.size() > 0) { return new BecauseDependentBuildIsBuilding(blockingProjects); } else { logger.info("No active dependencies on project: , it will now build", p); return null; } }