PMD report NullAssignment of the following code, what is the best practice to fix it?
NullAssignment
Assigning an Object to null is a code smell. Consider refactoring.
Assigning an Object to null is a code smell.
IMHO
After setting the Object/variable to null you can call System.gc() which forces the garbage collector to run Right Now.
null
System.gc()
I believe there will be no violations and code smell in that.