@Override public void run() { LOGGER.debug("Start running inspect Jobs..."); if (sleepTime == -1) { throw new RuntimeException("Sleep time has to be set before running this."); } while (!shouldStop) { Optional<List<JobV2>> jobListOpt = RepairnatorConfig.getInstance().getJTravis().job().allFromV2(); if (jobListOpt.isPresent()) { List<JobV2> jobList = jobListOpt.get(); LOGGER.info("Retrieved "+jobList.size()+" jobs"); for (JobV2 job : jobList) { if (this.rtScanner.isRepositoryInteresting(job.getRepositoryId())) { this.rtScanner.submitWaitingBuild(job.getBuildId()); } } } if (this.rtScanner.getInspectBuilds().maxSubmittedBuildsReached() || !jobListOpt.isPresent()) { LOGGER.debug("Max number of submitted builds reached. Sleep for "+sleepTime+" seconds."); try { Thread.sleep(sleepTime * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } } LOGGER.info("This will now stop."); } }