How to fix pmd violation “NullAssignment”?

前端 未结 3 1841
囚心锁ツ
囚心锁ツ 2021-01-23 19:42

PMD report NullAssignment of the following code, what is the best practice to fix it?

Assigning an Object to null is a code smell. Consider refactoring.

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 20:07

      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.

    I believe there will be no violations and code smell in that.

提交回复
热议问题