SonarQube: Community Edition Version 9.4 (build 54424)
SonarLint: 6.7.0.45926
Sonar highlights following code as a major bug, linking to rule “Java:S2259”
public <T> T getCacheValue(@NonNull String cacheName, @NonNull String key, Class<T> clazz) {
if (cacheManager.getCache(cacheName) != null) {
return cacheManager.getCache(cacheName).get(key, clazz);
}
return null;
}
cacheManager.getCache(cacheName) is null checked to avoid NullPointer, but Sonar gives allegedly false positive in this case