Called when there is a failure reading or writing to this connection. We notify the
connection manager and close ourselves down.
553404
public void networkFailure (IOException ioe)
    {
        // if we're already closed, then something is seriously funny
        if (isClosed()) {
            log.warning("Failure reported on closed connection " + this + ".", new Exception());
            return;
        }

        // let the connection manager know we're hosed
        _cmgr.connectionFailed(this, ioe);

        // and close our socket
        closeSocket();
    }
739376
public void stop()
	{
		try
		{
			stopping = true;
			myServerSocket.close();
			myThread.join();
		}
		catch ( IOException | InterruptedException e ) {
			logger.log(Level.WARNING, "Had unexpected exception during stop", e);
		}
	}
464171
public void onFailedUpgrade() {
        assert (this.state == ConnectionState.CONNECTING);
        ConnectionState event = null;
        synchronized (this) {
            this.state = ConnectionState.CLOSED;
            cleanClose = false;
            inputAvailable = false;
            outputAvailable = false;
            event = this.state;
        }
        notifyStateListeners(event);
    }
1014042
protected void connectionFailed (Connection conn, IOException ioe)
    {
        // remove this connection from our mappings (it is automatically removed from the Selector
        // when the socket is closed)
        _handlers.remove(conn.selkey);
        _connections.remove(conn.getConnectionId());
        _oflowqs.remove(conn);
        synchronized (this) {
            _stats.disconnects++;
        }
    }
906587
public static void closeQuietly(final Connection connection)
    {
        if (connection != null) {
            try {
                connection.close();
            }
            catch (JMSException je) {
                if (je.getCause() instanceof InterruptedException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedException");
                }
                if (je.getCause() instanceof InterruptedIOException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
                }
                else {
                    LOG.warnDebug(je, "While closing connection");
                }
            }
        }
    }
656254
protected void failAttempt(MemberState member, Throwable error) {
    // Reset the connection to the given member to ensure failed connections are reconstructed upon retries.
    context.getConnections().resetConnection(member.getMember().serverAddress());

    // If any append error occurred, increment the failure count for the member. Log the first three failures,
    // and thereafter log 1% of the failures. This keeps the log from filling up with annoying error messages
    // when attempting to send entries to down followers.
    int failures = member.incrementFailureCount();
    if (failures <= 3 || failures % 100 == 0) {
      logger.warn("{} - AppendRequest to {} failed: {}", context.getCluster().member().address(), member.getMember().address(), error.getMessage());
    }
  }
784398
public void close() {
        logger.debug("enter - close()");
        try {
            connection = null;
            data = null;        
            synchronized( executions ) {
                executions.add(this);
                executions.notifyAll();
            }
        }
        finally {
            logger.debug("exit - close()");
        }
    }
523909
public void close(ErrorCode rstStatusCode, @Nullable IOException errorException)
      throws IOException {
    if (!closeInternal(rstStatusCode, errorException)) {
      return; // Already closed.
    }
    connection.writeSynReset(id, rstStatusCode);
  }
1283142
void close() {
        if (logger.isLoggable(Level.FINER)) {
            logger.logp(Level.FINER, logger.getName(), "close", "Close called for " + RESTClientMessagesUtil.getObjID(this) + " within connection: "
                                                                + connector.getConnectionId());
        }

        closePollingThread();

        if (notificationRegistry != null) {
            notificationRegistry.close();
        }

        if (connector.logFailovers()) {
            String disconnectMsg = RESTClientMessagesUtil.getMessage(RESTClientMessagesUtil.MEMBER_DISCONNECT, connector.getCurrentEndpoint());
            logger.logp(Level.INFO, logger.getName(), "close", disconnectMsg);
        }

        disconnect();
    }
95608
def connectionLost(self, reason):
        """"""
        self.factory.loader.db.session.commit()
        if reactor.running:
            reactor.stop()
706788
public static void close (Reader in)
    {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ioe) {
                log.warning("Error closing reader", "reader", in, "cause", ioe);
            }
        }
    }
146621
@Override
	public final void close()
    {
    	externalAccessLock.writeLock().lock();
    	try
		{
	        if (closed)
	            return;
	        closed = true;
	        onConnectionClose();
		}
    	finally
    	{
    		externalAccessLock.writeLock().unlock();
    	}
    	onConnectionClosed();
    }
83583
public void connectionFailed (String ident, boolean readOnly, Connection conn,
                                  SQLException error)
    {
        try {
            conn.close();
        } catch (Exception e) {
            log.warning("Failure closing failed connection",
                        "ident", ident, "ro", readOnly, "conn", conn, e);
        }
    }
1012444
public void stopConnection() throws CommunicationException, KeystoreException {
		processedFailedNotifications();
		try {
			logger.debug("Closing connection");
			this.socket.close();
		} catch (Exception e) {
			/* Do not complain if connection is already closed... */
		}
	}
534581
private void notifyStoppedOrFailed(Throwable runException) {
        final Throwable stopException = this.stopException.get();
        if (runException == null) {
            // If runTask did not fail with an exception, see if we have a general stopException.
            runException = stopException;
        }

        if (runException instanceof CancellationException) {
            // CancellationExceptions are expected if we are shutting down the service; If this was the real
            // cause why runTask failed, then the service did not actually fail, so do not report a bogus exception.
            runException = null;
        }

        if (runException == null) {
            // Normal shutdown.
            notifyStopped();
        } else {
            if (stopException != null && stopException != runException) {
                // We have both a stopException and a runTask exception. Since the stopException came first, that is the
                // one we need to fail with, so add the runTask exception as suppressed.
                stopException.addSuppressed(runException);
                runException = stopException;
            }

            // Shutdown caused by some failure.
            notifyFailed(runException);

        }

        log.info("{}: Stopped.", this.traceObjectId);
    }
717732
def close(self):
        ''''''
        if self.writer:
            _logger.debug('Closing connection.')
            self.writer.close()

            self.writer = None
            self.reader = None

        if self._close_timer:
            self._close_timer.close()

        self._state = ConnectionState.dead
545838
void handleCommunicationIssue(Exception io) {
        // If we are connecting or disconnecting, note exception and leave
        statusLock.lock();
        try {
            if (this.connecting || this.disconnecting || this.status == Status.CLOSED || this.isDraining()) {
                this.exceptionDuringConnectChange = io;
                return;
            }
        } finally {
            statusLock.unlock();
        }

        processException(io);

        // Spawn a thread so we don't have timing issues with
        // waiting on read/write threads
        executor.submit(() -> {
            try {
                this.closeSocket(true);
            } catch (InterruptedException e) {
                processException(e);
            }
        });
    }