Description
Description
The updated
variable is checked after dereference. That is, if a null value is called in the if
block, an exception will be thrown and the code will not reach the updated
check for null.
Discussion
No response
Motivation
Code clarity and maintainability
Details
Even though the null check appears after the dereference of updated
, in practice, the method reference assigned to modelSupplier
- namely this::getPolicyModel()
- is implemented in such a way that it is not expected to return null. Specifically, getPolicyModel()
retrieves the policy via findById()
, and in this context the underlying data model and session cache are always initialized during usage. Therefore, the method modelSupplier.get()
is effectively guaranteed to return a non-null value.
Also, in case of an error, the code will throw an exception before reaching the if check.
Hence the check at the end of the code in the if
block is unreachable.
Found by Linux Verification Center with SVACE