PooledClientProvider has a fixed number of maximum clients it returns. This can lead to deadlock in application.
ThreadLocalClientProvider provides one client per thread, so there will be no deadlock. But there is no reliable way of closing the connection when the thread dies, and this leads to connection leaks.
Having a provider that has no limit on the number of clients returned will be equivalent to ThreadLocalClientProvider, since the number of clients requested can be capped by the number of threads, if each thread requests one client only. In addition, this provider is already resource leak proof as long as threads always return the clients after usage. If this provider can also timeout idle connections after some time, then this will ensure that we do not hold unnecessary connections when not required.
|