/**
   * Notifies that an application has closed the connection.
   *
   * <p>Remove and close the UserPoolItem associated with the PoolItem. If it's the last
   * UserPoolItem, move to the idle state.
   */
  public void connectionClosed(ConnectionEvent event) {
    Object handle = event.getConnectionHandle();

    if (!_hasConnectionError && handle == null && _shareHead != null) {
      log.fine(
          L.l(
              "JCA close event '{0}' for {1} did not have a connection handle.  Please notify the JCA resource provider.",
              event, _mConn));
    }

    UserPoolItem ptr = _shareHead;
    UserPoolItem prev = null;

    while (ptr != null) {
      UserPoolItem next = ptr.getShareNext();

      Object userConn = ptr.getUserConnection();

      if (userConn == handle || handle == null) {
        if (prev != null) prev.setShareNext(next);
        else _shareHead = next;

        ptr.close();
      } else prev = ptr;

      ptr = next;
    }

    if (_shareHead == null) {
      toIdle();
      return;
    }
  }