A lot of the MDA beans follow a convention (from the very early days of the code) that if a bean has local fields, they should be set to null during the doDestroy method.
This is (presumably) intended to make things easier for the Java garbage collection system to free up the now unreferenced objects. I think this is both a premature optimisation and in addition making assumptions about the garbage collector that may have been true a couple of decades ago that are unlikely to be true today.
Apart from being potentially ineffective and cluttering the code, this also makes both coverage analysis and some automated code analysis more difficult. It’s also in some cases forcing fields to be non-`final` when they could be final.
This should all be stripped out. In most cases, the doDestroy method can be removed entirely. We should also check that fields are converted to final where this change means that’s possible.
A lot of the MDA beans follow a convention (from the very early days of the code) that if a bean has local fields, they should be set to
null
during thedoDestroy
method.This is (presumably) intended to make things easier for the Java garbage collection system to free up the now unreferenced objects. I think this is both a premature optimisation and in addition making assumptions about the garbage collector that may have been true a couple of decades ago that are unlikely to be true today.
Apart from being potentially ineffective and cluttering the code, this also makes both coverage analysis and some automated code analysis more difficult. It’s also in some cases forcing fields to be non-`final` when they could be
final
.This should all be stripped out. In most cases, the
doDestroy
method can be removed entirely. We should also check that fields are converted tofinal
where this change means that’s possible.