src/main/java/com/sgoertzen/sonarbreak/QueryExecutor.java
private Result fetchSonarStatusWithRetries(URL queryURL, String version) throws IOException, SonarBreakException {
        DateTime oneMinuteAgo = DateTime.now().minusSeconds(sonarLookBackSeconds);
        DateTime waitUntil = DateTime.now().plusSeconds(waitForProcessingSeconds);
        do {
            // If this is the first time the job is running on sonar the URL might not be available.  Return null and wait.
            if (isURLAvailable(queryURL, 1)) {
                Result result = fetchSonarStatus(queryURL);
                if (result.getVersion().equals(version) && result.getDatetime().isAfter(oneMinuteAgo)) {
                    log.debug("Found a sonar job run that matches version and in the correct time frame");
                    return result;
                }
                String message = String.format("Sleeping while waiting for sonar to process job.  Target Version: %s.  " +
                                "Sonar reporting Version: %s.  Looking back until: %s  Last result time: %s", version,
                        result.getVersion(), oneMinuteAgo.toString(), result.getDatetime().toString());
                log.debug(message);
            } else {
                log.debug(String.format("Query url not available yet: %s", queryURL));
            }
            try {
                Thread.sleep(SONAR_PROCESSING_WAIT_TIME);
            } catch (InterruptedException e) {
                // Do nothing
            }
        } while (!waitUntil.isBeforeNow());

        String message = String.format("Timed out while waiting for Sonar.  Waited %d seconds.  This time can be extended " +
                "using the \"waitForProcessingSeconds\" configuration parameter.", waitForProcessingSeconds);
        throw new SonarBreakException(message);
    }
private Result fetchSonarStatusWithRetries(URL queryURL, String version) throws IOException, SonarBreakException {
        DateTime oneMinuteAgo = DateTime.now().minusSeconds(sonarLookBackSeconds);
        DateTime waitUntil = DateTime.now().plusSeconds(waitForProcessingSeconds);
        do {
            // If this is the first time the job is running on sonar the URL might not be available.  Return null and wait.
            if (isURLAvailable(queryURL, 1)) {
                Result result = fetchSonarStatus(queryURL);
                if (result.getVersion().equals(version) && result.getDatetime().isAfter(oneMinuteAgo)) {
                    log.debug("Found a sonar job run that matches version and in the correct time frame");
                    return result;
                }
                String message = String.format("Sleeping while waiting for sonar to process job.  Target Version: %s.  " +
                                "Sonar reporting Version: %s.  Looking back until: %s  Last result time: %s", version,
                        result.getVersion(), oneMinuteAgo.toString(), result.getDatetime().toString());
                log.debug(message);
            } else {
                log.debug(String.format("Query url not available yet: %s", queryURL));
            }
            try {
                Thread.sleep(SONAR_PROCESSING_WAIT_TIME);
            } catch (InterruptedException e) {
                // Do nothing
            }
        } while (!waitUntil.isBeforeNow());

        String message = String.format("Timed out while waiting for Sonar.  Waited %d seconds.  This time can be extended " +
                "using the \"waitForProcessingSeconds\" configuration parameter.", waitForProcessingSeconds);
        throw new SonarBreakException(message);
    }
Get the status from sonar for the currently executing build.  This waits for sonar to complete its processing
before returning the results.

@param queryURL The sonar URL to get the results from
@param version  The current project version number
@return Matching result object for this build
@throws IOException
@throws SonarBreakException