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;
}
}
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());
}
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());
}
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);
}
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());
}
Aggregations