JD.VNU.NULL
JD.VNU.NULL shows that the null value assigned to a variable was never read after assignment.
Vulnerability and risk
In most cases, it is just a redundant initialization code, but sometimes, it can signify a major logical error.
Mitigation and prevention
Optimize the code and remove the unused assignments.
Example 1
Copy
Reader prepareReader(Reader r) {
BufferedReader bufferedReader = null;
try {
bufferedReader = new BufferedReader(r);
register(bufferedReader);
} catch (Exception e) {
e.printStackTrace();
}
return bufferedReader;
}
private void register(BufferedReader bufferedReader) {
// ...
}
JD.VNU.NULL is reported for line 17: BufferedReader constructor does not throw exceptions, so the 'bufferedReader' variable is always reassigned on line 20.