Recent Posts
Archives

PostHeaderIcon Sonar / Dead store of null to local variable

How to fix the Sonar’s following report?
[java]Dodgy – Dead store of null to local variable[/java]

Remove assignments at null of local variables that will not be read. Since Java 6, they have no interest and no effect on garbage collector.
Eg: remove the last assignment, in the line#4 [java]void foo(){
String goo = "hello world";
(…)
goo = null;
}[/java]

Leave a Reply