The bug has nothing to do with automatic resource management. The try
block will execute getUtil()
each time the save()
method is called.
The problem lies in the PersistenceUtil
class; getUtil()
is returning a non-null PersistenceUtil
, but it's not behaving properly, and returns null
from getTransaction()
.