How to return objects to the Pool by timeout using apache commons pool
问题 I'm using Apache Commons Pool library to maintaing a pool of couchbase connections (can be seen as any kind of connection, doesn't really matter). The problem I'm facing is that the only way I've found to return objects to the pool is to do it programmatically by calling the returnObject method from the GenericObjectPool class. This forces the application to guarantee the return of the object once is borrowed from the pool, regardless any exception or unexpected behavior in the application.