ConnectionPoolComponentImpl implements ConnectionPoolComponent { @Override public void returnConnection(PoolableConnection connection) { requireNonNull(connection); leaseReturn(connection); if (!isValidOrNull(connection)) { discard(connection); } else { final String key = makeKey(connection); final Deque<PoolableConnection> q = acquireDeque(key); if (q.size() >= getMaxRetainSize()) { discard(connection); } else { LOGGER_CONNECTION.debug("Recycled: %s", connection); q.addFirst(connection); } } } @Inject  ConnectionPoolComponentImpl(
        final ConnectionDecorator connectionDecorator,
        final DbmsHandlerComponent dbmsHandlerComponent,
        final PasswordComponent passwordComponent,
        @Config(name = "connectionpool.maxAge", value = "30000") long maxAge,
        @Config(name = "connectionpool.maxRetainSize", value = "32") int maxRetainSize
    ); @ExecuteBefore(State.STOPPED) void closeOpenConnections(); @Override PoolableConnection getConnection(Dbms dbms); @Override PoolableConnection getConnection(
        final String uri,
        final String user,
        final char[] password
    ); @Override Connection newConnection(final Dbms dbms); @Override Connection newConnection(
        final String uri,
        final String username,
        final char[] password
    ); @Override void returnConnection(PoolableConnection connection); @Override int poolSize(); @Override int leaseSize(); @Override long getMaxAge(); @Override int getMaxRetainSize();  }
@Test void testReturnConnection() throws Exception { String uri = "thecooldatabase"; String user = "tryggve"; char[] password = "arne".toCharArray(); final PoolableConnection connection = instance.getConnection(uri, user, password); assertDoesNotThrow(() -> { instance.returnConnection(connection); }); }