Handles I/O error events from the network layer.

@param event the event
@throws IOException Signals that an I/O exception has occurred.
349214
@Handler(channels = NetworkChannel.class)
    public void onIoError(IOError event) throws IOException {
        for (Channel channel : event.channels()) {
            if (channel instanceof TcpChannel) {
                // Error while using established network connection
                TcpChannel netConnChannel = (TcpChannel) channel;
                Optional<WebAppMsgChannel> appChannel
                    = netConnChannel.associated(WebAppMsgChannel.class);
                if (appChannel.isPresent()) {
                    // Error while using a network connection
                    appChannel.get().handleIoError(event, netConnChannel);
                    continue;
                }
                // Just in case...
                pooled.remove(netConnChannel.remoteAddress(), netConnChannel);
                continue;
            }
            // Error while trying to establish the network connection
            if (event.event() instanceof OpenTcpConnection) {
                OpenTcpConnection connEvent
                    = (OpenTcpConnection) event.event();
                Optional<Set<WebAppMsgChannel>> erroneous;
                synchronized (connecting) {
                    erroneous = Optional
                        .ofNullable(connecting.get(connEvent.address()));
                    connecting.remove(connEvent.address());
                }
                erroneous.ifPresent(set -> {
                    for (WebAppMsgChannel chann : set) {
                        chann.openError(event);
                    }
                });
            }
        }
    }
621515
@Override
    public void error(VirtualConnection vc, TCPWriteRequestContext wsc, IOException ioe) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "error called: vc=" + vc + " ioe=" + ioe);
        }
        HttpInboundServiceContextImpl mySC = (HttpInboundServiceContextImpl) vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPISC);

        if (mySC.getHttpConfig().getDebugLog().isEnabled(DebugLog.Level.WARN)) {
            mySC.getHttpConfig().getDebugLog().log(DebugLog.Level.WARN, HttpMessages.MSG_WRITE_FAIL, mySC);
        }
        mySC.logLegacyMessage();
        // pass on the error if possible, else just close the connection
        mySC.setPersistent(false);
        if (null != mySC.getAppWriteCallback()) {
            mySC.getAppWriteCallback().error(vc, ioe);
        } else {
            mySC.getLink().getDeviceLink().close(vc, ioe);
        }
    }
627571
private void handleIOException(IOException e, String action, int attempt)
            throws VoldemortException, InterruptedException {
        if ( // any of the following happens, we need to bubble up
                // FileSystem instance got closed, somehow
                e.getMessage().contains("Filesystem closed") ||
                // HDFS permission issues
                ExceptionUtils.recursiveClassEquals(e, AccessControlException.class)) {
            throw new VoldemortException("Got an IOException we cannot recover from while trying to " +
                    action + ". Attempt # " + attempt + "/" + maxAttempts + ". Will not try again.", e);
        } else {
            logFailureAndWait(action, IO_EXCEPTION, attempt, e);
        }
    }
431500
public function error(MvcEvent $event): void
    {
        if (
            true === $this->tracyOptions->getEnabled()
            && null !== $event->getParam('error')
            && null !== $event->getParam('exception')
        ) {
            ob_clean();

            throw $event->getParam('exception');
        }
    }
677359
@Override
    public void ioErrorRaised(IoErrorRaisedEvent event) throws InterruptedException {
        String message = "I/O error raised when polling directory '%s'!";
        PolledDirectory dir = event.getPolledDirectory();
        IOException e = event.getIoException();
        LOG.error(String.format(message, dir), e);
    }
328831
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
    public void invoke(EventBase<?> event) throws Throwable {
        // ADAPT VERBOSEHANDLERREFERENCE TO ANY CHANGES MADE HERE
        switch (method.type().parameterCount()) {
        case 0:
            // No parameters
            method.invoke();
            break;

        case 1:
            // Event parameter
            method.invoke(event);
            break;

        case 2:
            // Event and channel
            Class<?> channelParam = method.type().parameterType(1);
            for (Channel channel : event.channels()) {
                if (channelParam.isAssignableFrom(channel.getClass())) {
                    method.invoke(event, channel);
                }
            }
            break;

        default:
            throw new IllegalStateException("Handle not usable");
        }
    }
236005
@Override
  public final void error(String error) throws IOException {
    add(false);
    setError(newCurrentPosition, error, newCurrentExisting);
  }
334082
public void processEvent(EventObject event) // for asynchronous
  // (nonblocking) response
  // handling
  {
    synchronized (this) {
    } // wail til message sending has finished (transaction attribute set)

    if (event instanceof ResponseEvent) {
      processResponse((ResponseEvent) event);
    } else if (event instanceof TimeoutEvent) {
      processTimeout((TimeoutEvent) event);
    }

    // note, requests don't come through here, they are handled via the
    // listen/waitFor methods.
  }
1107623
public void error(VirtualConnection vc, TCPReadRequestContext req, IOException ioe) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "error: " + vc);
        }
        // This can legitemately happen if the client closes
        // the connection before sending data - we will always get
        // an exception in that case
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Error occurred during initial read of request from client: " + req.getInterface().getRemoteAddress() + " " + req.getInterface().getRemotePort() + " : "
                         + ioe);
        }

        // release any WsByteBuffers that were allocated for this request
        WsByteBuffer buffArray[] = req.getBuffers();
        if (buffArray != null) {
            for (int i = 0; i < buffArray.length; i++) {
                if (buffArray[i] != null) {
                    buffArray[i].release();
                }
            }
        }
        req.setBuffers(null);

        // if read timed out, send to discriminators so that they
        // can send error response if necessary
        if (ioe != null && ioe instanceof SocketTimeoutException) {
            sendToDiscriminators(vc, req, true);
        } else {
            // Destroy the connection link
            ((TCPReadRequestContextImpl) req).getTCPConnLink().close(vc, ioe);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "error");
        }
    }
1258150
public <E> void dispatchEvent (Signal<E> signal, E event) {
    try {
      signal.emit(event);
    } catch (Throwable cause) {
      reportError("Event dispatch failure", cause);
    }
  }
244824
@MainThread
    private void handleEventFailure(Event event, EventFailure failure) {
        if (!activeEvents.contains(event)) {
            Utils.logE(event.getKey(), "Cannot send failure callback of finished event");
            return;
        }

        scheduleFailureCallbacks(event, failure);
        executeTasks(false);
    }
511754
public void handleEvent(SystemHookEvent event) throws GitLabApiException {
        if (event != null) {
            LOGGER.info("handleEvent:" + event.getClass().getSimpleName() + ", eventName=" + event.getEventName());
            fireEvent(event);
        } else {
            LOGGER.warning("handleEvent: provided event cannot be null!");
        }
    }
598879
@Handler(channels = EncryptedChannel.class)
    public void onIOError(IOError event, IOSubchannel encryptedChannel)
            throws SSLException, InterruptedException {
        @SuppressWarnings("unchecked")
        final Optional<PlainChannel> plainChannel
            = (Optional<PlainChannel>) LinkedIOSubchannel
                .downstreamChannel(this, encryptedChannel);
        plainChannel.ifPresent(channel -> fire(new IOError(event), channel));
    }
1313017
public void write(IRTMPEvent event) {
        if (!connection.isClosed()) {
            final IClientStream stream = connection.getStreamByChannelId(id);
            if (id > 3 && stream == null) {
                log.warn("Non-existant stream for channel id: {}, session: {} discarding: {}", id, connection.getSessionId(), event);
            }
            // if the stream is non-existant, the event will go out with stream id == 0
            final Number streamId = (stream == null) ? 0 : stream.getStreamId();
            write(event, streamId);
        } else {
            log.debug("Connection {} is closed, cannot write to channel: {}", connection.getSessionId(), id);
        }
    }
721331
@Override
    public void connectionErrorOccurred(ConnectionEvent event) {

        int eventID = event.getId();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            StringBuilder entry = new StringBuilder(event.getClass().getSimpleName()).append('{');
            entry.append("id=").append(event.getId()).append(", ");
            entry.append("source=").append(event.getSource());
            entry.append('}');

            if (event.getException() == null)
                Tr.entry(this, tc, "connectionErrorOccurred", entry.toString());
            else
                Tr.entry(this, tc, "connectionErrorOccurred", entry.toString(), event.getException());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            // (ASSERT: event is not null)
            StringBuffer tsb = new StringBuffer();
            Object connHandle = event.getConnectionHandle();
            tsb.append("***Connection Error Request*** Handle Name: " + connHandle);
            if (mcWrapper != null) {
                Object poolMgr = mcWrapper.getPoolManager();
                tsb.append(", Connection Pool: " + poolMgr + ", Details: " + mcWrapper);
            } else {
                tsb.append(", Details: null");
            }
            Tr.debug(this, tc, tsb.toString());
        }

        switch (eventID) {

            case ConnectionEvent.CONNECTION_ERROR_OCCURRED: {

                Exception tempEx = event.getException();

                // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception
                String tempString = "";
                if (tempEx != null) {

                    // If there is an associated Exception, generate tempString from that
                    tempString = J2CUtilityClass.generateExceptionString(tempEx);
                    Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName);

                }

                else {
                    Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName);
                }

                // NOTE: Moving all functional code for this to the MCWrapper as it is
                //  closer to all the data/objects needed to perform this cleanup.
                mcWrapper.connectionErrorOccurred(event);

                break;
            }

            case com.ibm.websphere.j2c.ConnectionEvent.SINGLE_CONNECTION_ERROR_OCCURRED: {

                /*
                 * 51 is the id selected for this event.
                 *
                 * If a resource adapter uses this Id, the connection may be
                 * unconditionally cleaned up and destroyed. We are assuming the resource
                 * adapter knows this connection can not be recovered.
                 *
                 * Existing transactions may delay destroying the connection.
                 *
                 * The connectionErrorOccurred method will process this request,
                 *
                 * Only this connection will be destroyed.
                 */

                Exception tempEx = event.getException();

                // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception
                String tempString = "";
                if (tempEx != null) {

                    // If there is an associated Exception, generate tempString from that
                    tempString = J2CUtilityClass.generateExceptionString(tempEx);
                    Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName);
                }

                else {
                    Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName);
                }

                // NOTE: Moving all functional code for this to the MCWrapper as it is
                // closer to all the data/objects needed to perform this cleanup.
                mcWrapper.connectionErrorOccurred(event);

                break;
            }

            case com.ibm.websphere.j2c.ConnectionEvent.CONNECTION_ERROR_OCCURRED_NO_EVENT: {

                // NOTE: Moving all functional code for this to the MCWrapper as it is
                //  closer to all the data/objects needed to perform this cleanup.
                mcWrapper.connectionErrorOccurred(event);

                break;
            }

            default: {

                // Connection Event passed in doesn't match the method called.
                // This should never happen unless there is an error in the ResourceAdapter.
                processBadEvent("connectionErrorOccurred", ConnectionEvent.CONNECTION_ERROR_OCCURRED, event);

            }

        } // end switch

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "connectionErrorOccurred");
        }

        return;

    }
89652
protected synchronized void connectionFailed (final IOException ioe)
    {
        // make sure the socket isn't already closed down (meaning we've already dealt with the
        // failed connection)
        if (_channel == null) {
            return;
        }

        log.info("Connection failed", ioe);

        // let the client know that things went south
        notifyClientObservers(new ObserverOps.Client(_client) {
            @Override protected void notify (ClientObserver obs) {
                obs.clientConnectionFailed(_client, ioe);
            }
        });

        // and request that we go through the motions of logging off
        logoff();
    }
280130
@Override
    public void handleEvent(Event event) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Received event: " + event.getTopic());
        }
        // if (event.getTopic().equals(PURGE_EVENT)) {
        this.sessionMgr.startPurge();
        // }
    }