Search
Calendar
May 2017
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
28293031  
Your widget title
Archives

PostHeaderIcon Sonar / Dead store of null to local variable

How to fix the Sonar’s following report?

Dodgy - Dead store of null to local variable

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

void foo(){
    String goo = "hello world";
    (...)
    goo = null;
}

Leave a Reply