Search in sources :

Example 91 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class InternalCeQueueImpl method getStackTraceForPersistence.

@CheckForNull
private static String getStackTraceForPersistence(Throwable error) {
    try (ByteArrayOutputStream out = new ByteArrayOutputStream();
        LineReturnEnforcedPrintStream printStream = new LineReturnEnforcedPrintStream(out)) {
        error.printStackTrace(printStream);
        printStream.flush();
        return out.toString();
    } catch (IOException e) {
        Logger.getLogger(InternalCeQueueImpl.class).debug("Failed to getStacktrace out of error", e);
        return null;
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) CheckForNull(javax.annotation.CheckForNull)

Example 92 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class PeriodResolver method findByPreviousVersion.

@CheckForNull
private Period findByPreviousVersion() {
    if (currentVersion == null) {
        return null;
    }
    List<SnapshotDto> snapshotDtos = dbClient.snapshotDao().selectPreviousVersionSnapshots(session, projectUuid, currentVersion);
    if (snapshotDtos.isEmpty()) {
        // If no previous version is found, the first analysis is returned
        return findByFirstAnalysis();
    }
    SnapshotDto snapshotDto = snapshotDtos.get(0);
    LOG.debug("Compare to previous version ({})", formatDate(snapshotDto.getCreatedAt()));
    return new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, snapshotDto.getVersion(), snapshotDto.getCreatedAt(), snapshotDto.getUuid());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) Period(org.sonar.server.computation.task.projectanalysis.period.Period) CheckForNull(javax.annotation.CheckForNull)

Example 93 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class PeriodResolver method findByFirstAnalysis.

@CheckForNull
private Period findByFirstAnalysis() {
    SnapshotDto snapshotDto = dbClient.snapshotDao().selectOldestSnapshot(session, projectUuid);
    if (snapshotDto == null) {
        return null;
    }
    LOG.debug("Compare to first analysis ({})", formatDate(snapshotDto.getCreatedAt()));
    return new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, snapshotDto.getCreatedAt(), snapshotDto.getUuid());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) Period(org.sonar.server.computation.task.projectanalysis.period.Period) CheckForNull(javax.annotation.CheckForNull)

Example 94 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class PeriodResolver method resolve.

@CheckForNull
private Period resolve(String property) {
    Integer days = tryToResolveByDays(property);
    if (days != null) {
        return findByDays(days);
    }
    Date date = DateUtils.parseDateQuietly(property);
    if (date != null) {
        return findByDate(date);
    }
    if (StringUtils.equals(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, property)) {
        return findByPreviousAnalysis();
    }
    if (StringUtils.equals(LEAK_PERIOD_MODE_PREVIOUS_VERSION, property)) {
        return findByPreviousVersion();
    }
    return findByVersion(property);
}
Also used : Date(java.util.Date) CheckForNull(javax.annotation.CheckForNull)

Example 95 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class PeriodResolver method findByPreviousAnalysis.

@CheckForNull
private Period findByPreviousAnalysis() {
    SnapshotDto snapshot = findFirstSnapshot(session, createCommonQuery(projectUuid).setCreatedBefore(analysisDate).setIsLast(true).setSort(BY_DATE, DESC));
    if (snapshot == null) {
        return null;
    }
    LOG.debug("Compare to previous analysis ({})", formatDate(snapshot.getCreatedAt()));
    return new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, formatDate(snapshot.getCreatedAt()), snapshot.getCreatedAt(), snapshot.getUuid());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) Period(org.sonar.server.computation.task.projectanalysis.period.Period) CheckForNull(javax.annotation.CheckForNull)

Aggregations

CheckForNull (javax.annotation.CheckForNull)149 IOException (java.io.IOException)18 Tree (org.apache.jackrabbit.oak.api.Tree)16 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)12 ArrayList (java.util.ArrayList)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)9 Stopwatch (com.google.common.base.Stopwatch)8 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)8 Date (java.util.Date)7 SnapshotDto (org.sonar.db.component.SnapshotDto)7 Period (org.sonar.server.computation.task.projectanalysis.period.Period)7 File (java.io.File)6 SQLException (java.sql.SQLException)6 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)6 ExecutionException (java.util.concurrent.ExecutionException)5 ValidationModel (org.apache.sling.validation.model.ValidationModel)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4 Root (org.apache.jackrabbit.oak.api.Root)4 Utils.resolveCommitRevision (org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4