-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
Component/s: provisioning
-
None
Provisioners implement a single instance of a DAO subclass to implement the API calls. If the DAO needs to log in before the run, this is easy because it can just do it when retrieving the external system. But there is no way to call a logout method. The DAO instance just goes out of scope at some point, and any sessions to the remote server are never cleaned up.
Java method finalize() is deprecated so not an option. Implementing Autoclosable is not an option because the DAO isn't called using try-with-resources. The only way that sort of works is by instantiating a java.lang.ref.Cleaner object with a custom Runnable class to do the cleanup. This seems to work, although it sometimes takes a few minutes before the logout is triggered. In addition to the delay, it's a little advanced coding to get it to work.
If the DAO base class implemented an empty cleanup method, and called it before the end of the full and incremental jobs, DAO classes could implement it in a more straightforward way, and with better timing.