Description:
Load-balanced/failover connections cause memory leak if were not closed explicitly.
AbandonedConnectionCleanupThread should take care about such connections, but the problem is that refQueue keeps references to underlying ConnectionImpls not to the top object (LoadBalancingConnectionProxy eg.). So when application lost reference to the top connection object this object remains in strong references from ConnectionImpls and at the same time keeps strong references to these objects.
How to repeat:
Make a loop with steps:
1) create l-b connection;
2) assign null to this connection reference
Suggested fix:
1) Pass l-b object to NonRegisteringDriver.trackConnection(Connection newConn) instead of ConnectionImpls
2) Keep reference from ConnectionImpl to proxy as WeakReference.