Override comb.collections.Pool to allow async validation to allow
pools to do any calls to reset a connection if it needs to be done.

@param {*} connection the connection to return.
767109
function (obj) {
            var self = this;
            this.validate(obj).chain(function (valid) {
                var index;
                if (self.count <= self.__maxObjects && valid && (index = self.__inUseObjects.indexOf(obj)) > -1) {
                    self.__inUseObjects.splice(index, 1);
                    self.__freeObjects.enqueue(obj);
                    self.__checkQueries();
                } else {
                    self.removeObject(obj);
                }
            });
        }
321239
public void free(Connection connection) {
        try {
            if (!connection.isClosed()){
                // ensure connections returned to pool as read-only
                setConnectionReadOnly(connection, true);
                connection.close();
            } else {
                logger.debug("Ignoring attempt to close a previously closed connection");
            }
        } catch (SQLException sqle) {
            logger.warn("Unable to close connection", sqle);
        } finally {
            if (logger.isDebugEnabled()) {
                logger.debug("Returned connection to pool (" + toString() + ")");
            }
        }
    }
330741
def release(self, connection):
        
        self._checkpid()
        if connection.pid != self.pid:
            return

        # Remove the current connection from _in_use_connection and add it back to the available pool
        # There is cases where the connection is to be removed but it will not exist and there
        # must be a safe way to remove
        i_c = self._in_use_connections.get(connection.node["name"], set())
        if connection in i_c:
            i_c.remove(connection)
        else:
            pass
        # discard connection with unread response
        if connection.awaiting_response:
            connection.disconnect()
            # reduce node connection count in case of too many connection error raised
            if self.max_connections_per_node and self._created_connections_per_node.get(connection.node['name']):
                self._created_connections_per_node[connection.node['name']] -= 1
        else:
            self._available_connections.setdefault(connection.node["name"], []).append(connection)
1107510
function(pool) {
    let toRemove = Math.max(1, pool.idleConnections() - opts.minimumIdle);
    while (toRemove > 0) {
      const conn = idleConnections.peek();
      --toRemove;
      if (conn && conn.lastUse + opts.idleTimeout * 1000 < Date.now()) {
        idleConnections.shift();
        conn.forceEnd().catch(err => {});
        conn.releaseWithoutError();
        continue;
      }
      break;
    }
    ensurePoolSize(pool);
  }
855361
function _checkConnection(conn) {
  // Return Promise for getConnection callback wrapping
  return new Promise((resolve, reject) => {
    if (conn) {
      resolve(conn);
    } else {
      _pool.getConnection((err, conn) => {
        if (err) reject(err); // Reject this error
        else resolve(conn); // Resolve the connection
      })
    }
  });
}
1174077
public void connectionDidJoin(final RespokeConnection connection) {
        members.add(connection);

        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Listener listener = listenerReference.get();
                if (null != listener) {
                    listener.onJoin(connection, RespokeGroup.this);
                }
            }
        });
    }
205894
function () {
        // just to be sure! clear all items in the connections object. they should be cleared by now
        util.each(this.connections, function (value, prop, conns) {
            try {
                value.release();
            }
            catch (e) { } // nothing to do with error
            delete conns[prop];
        });

        // now execute end on the databases. will end pool if pool, or otherwise will execute whatever
        // `end` that has been exposed by db.js
        util.each(Transaction.databases, function (value, prop, databases) {
            value.end();
            databases[prop] = null;
        });
    }
167912
protected void rollbackLocalConnection(Connection connection) {
    try {
      if (connection != null) {
        connection.rollback();
      }
    } catch (Exception e) {
      if (logger.isTraceEnabled()) {
        logger.trace(e.getMessage());
      }
    }
  }
832209
function RpcChannel(connection) {
    if (!connection) {
        var msg = 'The connection is mandatory!';
        logger.error(msg);
        throw new TypeError(msg);
    }
    this._connection = connection;
    this._open = true;
    this._queue = [];
    var self = this;
    setInterval(function () {
        executor.call(self);
    }, 100).unref();
}
1120322
public static synchronized void registerCCMConnection(String poolName, Object mcp, Object cl,
                                                         Object connection, String key)
   {
      log.tracef("%s", new TraceEvent(poolName,
                                      Integer.toHexString(System.identityHashCode(mcp)),
                                      TraceEvent.REGISTER_CCM_CONNECTION,
                                      Integer.toHexString(System.identityHashCode(cl)),
                                      Integer.toHexString(System.identityHashCode(connection)),
                                      key));
   }
1028525
function (connectionName, cb) {
            var closeConnection = function (connectionName) {
                var connection = me.connections[connectionName];
                if (connection) {
                    if (connection.conn && typeof connection.conn.close === 'function') {
                        connection.conn.close(function (err) {
                            if (err) console.error(err);
                        });
                    }
                    else {
                        connection.close(function (err) {
                            if (err) console.error(err);
                        });
                    }
                }

                delete me.connections[connectionName];
            };

            if (connectionName) closeConnection(connectionName);
            else _.each(me.connections, closeConnection);

            return cb();
        }
221473
ServerSessionManager unregisterConnection(Connection connection) {
    Iterator<Map.Entry<String, Connection>> iterator = connections.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<String, Connection> entry = iterator.next();
      if (entry.getValue().equals(connection)) {
        ServerSessionContext session = clients.get(entry.getKey());
        if (session != null) {
          session.setConnection(null);
        }
        iterator.remove();
      }
    }
    return this;
  }
320507
public void releaseConnection(IPhynixxManagedConnection<C> connection) {
        if (connection == null || !connection.hasCoreConnection()) {
            return;
        }
        try {
            //StringBuilder builder= new StringBuilder(Thread.currentThread().getId()+".releaseConnection starting from "+this.genericObjectPool.getNumIdle()+"/"+this.genericObjectPool.getNumActive());
            this.genericObjectPool.returnObject(connection);
            // LOG.debug(builder.append(" ... to "+Thread.currentThread().getId()+"   "+this.genericObjectPool.getNumIdle()+"/"+this.genericObjectPool.getNumActive()).toString());

        } catch (Exception e) {
            throw new DelegatedRuntimeException(e);
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Proxy " + connection + " returned to Pool");
        }
    }
997853
function(connection, collection, relations, cb) {
      log.debug('drop:', collection);
      // Add in logic here to delete a collection (e.g. DROP TABLE logic)

      return connections[connection].drop(collection, relations, cb);
    }
75883
function(callback)
    {
        self.pool = (require('mysql')).createPool({
            user     : self.config.username,
            password : self.config.password,
            database : self.config.db,
            host     : self.config.host,
            port     : self.config.port
        });

        // Initiate a connection - just to proof configuration
        self.pool.getConnection(function(err, connection) {

            if (err || !connection) {
                callback && callback(err);
                return;
            }

            self.prepare(connection);

            // The connection can be closed immediately
            connection.release();
            return callback && callback(null, self.pool);
        });
    }
175957
function () {
        // release all pending connections
        util.each(this.connections, function (connection, threadId, connections) {
            try {
                connection.release();
            }
            catch (e) { } // nothing to do with error
            delete connections[threadId];
        });

        // execute end on the db. will end pool if pool, or otherwise will execute whatever `end` that has been
        // exposed by db.js
        util.each(this.sources, function (source, identity, sources) {
            try {
                source && source.end();
            }
            catch (e) { } // nothing to do with error
            delete sources[identity];
        });
    }
1048019
private void onCleanup(Object connection)
    {
        // if not running within transaction boundary
        if (this.connection != null)
        {
            if (settings != null)
            {
                ((Jedis) connection).configResetStat();
            }
            factory.releaseConnection((Jedis) this.connection);
        }

        this.connection = null;
    }