SonarQube quality fails with possible NullPointer
in the method
When calling the method I'm checking !=null, but not passing through
private Asset findAsset(List<Asset> assets, Long assetId) {
return assets.parallelStream()
.filter(ast -> ast.getAssetId().equals(assetId))
.findFirst()
.orElse(null);
}
Im trying the below code:
if (findAsset(assetCompositionList, pair.getKey()) != null) {
assetMap.put(pair.getKey(),
findAsset(assets, pair.getKey()).getAssetCode());
}
I was already checking !=null
in findAsset()
method when called.