private void onError(Exception e) { // TODO: currently unused
    localTransaction = null;

    synchronized (connections) {
      List<GFConnectionImpl> connectionsToRemove = new LinkedList<>(connections);
      for (GFConnectionImpl connection : connections) {
        connection.invalidate();
        connectionsToRemove.add(connection);
        synchronized (listeners) {
          ConnectionEvent event =
              new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
          event.setConnectionHandle(connection);
          for (ConnectionEventListener listener : listeners) {
            listener.connectionErrorOccurred(event);
          }
        }
      }
      connections.removeAll(connectionsToRemove);
    }
  }
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