Search in sources :

Example 1 with JavaReadCache

use of org.sonar.plugins.java.api.caching.JavaReadCache in project sonar-java by SonarSource.

the class ExcessiveContentRequestCheck method loadFromPreviousAnalysis.

private static Optional<CachedResult> loadFromPreviousAnalysis(CacheContext cacheContext, InputFile inputFile) {
    JavaReadCache readCache = cacheContext.getReadCache();
    String cacheKey = computeCacheKey(inputFile);
    byte[] rawValue = readCache.readBytes(cacheKey);
    if (rawValue == null) {
        return Optional.empty();
    }
    try {
        return Optional.ofNullable(CachedResult.fromBytes(rawValue));
    } catch (IllegalArgumentException ignored) {
        LOGGER.trace(() -> String.format("Cached entry is unreadable for rule java:S5693 on file %s", inputFile));
        return Optional.empty();
    }
}
Also used : JavaReadCache(org.sonar.plugins.java.api.caching.JavaReadCache)

Aggregations

JavaReadCache (org.sonar.plugins.java.api.caching.JavaReadCache)1