public void onClose(GFConnectionImpl connection) {
    connection.invalidate();
    connections.remove(connection);

    synchronized (listeners) {
      ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
      event.setConnectionHandle(connection);
      for (ConnectionEventListener listener : listeners) {
        listener.connectionClosed(event);
      }
    }

    if (connections.isEmpty()) {
      // safe to dissociate this managed connection so that it can go to pool
      if (initialized && !isCacheClosed()) {
        localTransaction = new JCALocalTransaction(cache, transactionManager);
      } else {
        localTransaction = new JCALocalTransaction();
      }
    }
  }
Invalidate and remove the {@link GFConnectionImpl} from the connections collection.
The approach to use removeAll instead of Iterator.remove is purely a performance optimization
to avoid creating all the intermediary collections that will be created when using the single
remove operation.
geode-core/src/jca/java/org/apache/geode/internal/ra/spi/JCAManagedConnection.java