Affects PMD Version:
6.9.0
Rule:
PrematureDeclaration
Description:
The result of a ConcurrentMap#put is captured for handling later in the method. As put has a side effect, the logic changes if the declaration is moved downward.
Code Sample demonstrating the issue:
var prior = cache.put(uri, cachedPath);
if (ref == null) {
return PathRef.create(cachedPath, 1);
}
if (prior == null) {
ref.count().incrementAndGet();
}
Affects PMD Version:
6.9.0
Rule:
PrematureDeclaration
Description:
The result of a
ConcurrentMap#putis captured for handling later in the method. Asputhas a side effect, the logic changes if the declaration is moved downward.Code Sample demonstrating the issue: