DOUGLAS.SURBER at oracle.com
Thu Jan 25 15:08:30 UTC 2018
I’ve added a new method to Connection. I’m not sure it is the right way to address the issue, though.
* Wait for all member Operations of this Connection to complete.
* ISSUE: Use this method or require implementations to have some mechanism
* to keep the JVM from exiting before all member Operations complete? App could
* call abort if it wants to quit. That seems less surprising, but join is
* easier to implement.
* @throws IllegalStateException if this Connection has not been submitted.
* @return the value of the Connection
public Object join();
An implementation uses background threads to do work. Those are most likely daemon threads. There needs to be a way to insure that those threads complete before the JVM exits. One way would be to require the implementation take responsibility for this. The alternative is to make the user responsible, ie the join() method above. If the implementation is responsible then the user can force the implementation to finish by Connection.abort. The Principle of Least Surprise suggests making the implementation responsible.
On the other hand I haven’t thought of a good way for an implementation to be responsible. The implementation could register a shutdownHook that waits for all pending Operations to complete. Insuring that an implementation unregisters the shutdownHook when appropriate adds a lot of machinery I’d prefer to avoid. Also, since the order in which shutdownHooks run is not determined, there is no reason to believe that the rest of the system is in a proper state for ADBA to continue to run.
More information about the jdbc-spec-discuss