Closes socket and stream readers/writers

@throws org.drizzle.jdbc.internal.common.QueryException
if the socket or readers/writes cannot be closed
4714
public void close() throws QueryException {
        try {
            if(! (socket instanceof SSLSocket))
                socket.shutdownInput();
        } catch (IOException ignored) {
        }
        try {
            final ClosePacket closePacket = new ClosePacket();
            closePacket.send(writer);
            if (! (socket instanceof SSLSocket))
                socket.shutdownOutput();
            writer.close();
            packetFetcher.close();
        } catch (IOException e) {
            throw new QueryException("Could not close connection: " + e.getMessage(),
                    -1,
                    SQLExceptionMapper.SQLStates.CONNECTION_EXCEPTION.getSqlState(),
                    e);
        } finally {
            try {
                this.connected = false;
                socket.close();
            } catch (IOException e) {
                log.warning("Could not close socket");
            }
        }
        this.connected = false;
    }
1342844
@Override
    public void close() throws IOException
    {
        InputStream in = mIn;

        if (in != null) {
            mIn = null;
            freeBuffers();
            in.close();
        }
    }
1217778
@Override
  public void close() throws SQLException {
    if (queryExecutor == null) {
      // This might happen in case constructor throws an exception (e.g. host being not available).
      // When that happens the connection is still registered in the finalizer queue, so it gets finalized
      return;
    }
    releaseTimer();
    queryExecutor.close();
    openStackTrace = null;
  }
488134
public void abort() {
    this.explicitClosed = true;

    boolean lockStatus = false;
    if (lock != null) {
      lockStatus = lock.tryLock();
    }
    this.connected = false;

    abortActiveStream();

    if (!lockStatus) {
      //lock not available : query is running
      // force end by executing an KILL connection
      forceAbort();
      try {
        socket.setSoLinger(true, 0);
      } catch (IOException ioException) {
        //eat
      }
    } else {
      SendClosePacket.send(writer);
    }

    closeSocket(reader, writer, socket);
    cleanMemory();
    if (lockStatus) {
      lock.unlock();
    }
  }
313125
public static void close(Socket socket) {
        if (socket == null) {
            return;
        }
        try {
            socket.close();
        } catch (IOException e) {
            Logger.getLogger(IOUtil.class).finest("closeResource failed", e);
        }
    }
175036
@SuppressWarnings("resource")
	@Override
	public void close() throws IOException {
		if (this.tmpFile.canRead()) {
			try {
				this.tmpOutput.close();

				try (WritableByteChannel out = Channels.newChannel(this.output)) {
					try (ReadableByteChannel in = Channels.newChannel(new FileInputStream(this.tmpFile))) {
						// Write the header
						final int limit = HEADER_KEY.getBytes().length + 6;
						final ByteBuffer hBuffer = ByteBuffer.allocate(limit);
						hBuffer.limit(limit);
						in.read(hBuffer);
						hBuffer.position(HEADER_KEY.getBytes().length + 2);
						hBuffer.putInt(this.length);
						hBuffer.rewind();
						out.write(hBuffer);
						// Write the objects
						final ByteBuffer buffer = ByteBuffer.allocate(4096);
						int read;
						while ((read = in.read(buffer)) >= 0) {
							buffer.rewind();
							buffer.limit(read);
							out.write(buffer);
							buffer.rewind();
							buffer.limit(buffer.capacity());
						}
					}
				}
			} finally {
				this.tmpFile.delete();
			}
		}
	}
974225
public static void closeQuietly(@Nullable Socket socket, @Nullable Writer writer) {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {

            }
        }
        closeQuietly(socket);
    }
698952
@Override
  protected void close() {
    this.stop = true;

    // Close the socket to force blocking operations to return.
    if (this.socket != null && !this.socket.isClosed()) {
      this.socket.close();
    }
  }
1091357
public void close() throws IOException {   
    if (closed) {
      checkWriteThread();
      return;
    }
    try {
      buffer.close(); 
      // writeThread should exit after this
      // and close underlying stream
      try {
        writeThread.join();
      } catch (InterruptedException e) {
        throw new IOException(e);
      }
    } finally {
      checkWriteThread();
    }
  }
605281
public void close() {
        done = true;
        connected = false;
        synchronized (this) {
            try {
                if (socket != null) {
                    if (traceLevel >= ctrlThreshold) {
                        System.out.println("-> CLOSE");
                    }
                    socket.close();
                }
            } catch (final IOException e) { /* ignore socket close errors */
            } finally {
                socket = null;
            }
        }
    }
49923
@Override
    public void close() throws IOException {
        if (isClosed) {
            return;
        }
        flush(sendEor);
        if (sendClose) {
            eventPipeline.fire(new Close(), channel);
        }
        isClosed = true;
    }
149113
protected void close() throws IOException {
        synchronized(fdLock) {
            if (fd != null && fd.valid()) {
                if (!stream) {
                    ResourceManager.afterUdpClose();
                }
                if (closePending) {
                  return;
                }
                closePending = true;
                socketClose();
                return;
            }
        }
    }
692063
public void close() throws IOException {
        if (dataStream != null) dataStream.close();
        byteStream = null;
        dataStream = null;
    }
549081
public void close()
    throws IOException
  {
    ServerSocket ss = _ss;
    _ss = ss;

    if (ss != null) {
      try {
        ss.close();
      } catch (Exception e) {
      }
    }
  }
1019531
@Override
  public void close() throws IOException {
    if (encodingWriter != null) {
      encodingWriter.close();
    }

    pgOutput.close();
    pgInput.close();
    connection.close();
  }
1259925
synchronized void closeSocket() {

        @Nullable SocketChannel clientChannel = this.clientChannel;

        if (clientChannel != null) {

            try {
                clientChannel.socket().shutdownInput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            try {
                clientChannel.socket().shutdownOutput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            Closeable.closeQuietly(clientChannel);

            this.clientChannel = null;

            if (LOG.isDebugEnabled())
                Jvm.debug().on(getClass(), "closing", new StackTrace("only added for logging - please ignore !"));

            @NotNull final TcpSocketConsumer tcpSocketConsumer = this.tcpSocketConsumer;

            tcpSocketConsumer.tid = 0;
            tcpSocketConsumer.omap.clear();

            onDisconnected();

        }
    }
471414
@Override
	public void close()
	{
		LOG.debug("Going to close tcp connection in class: {}", this
				.getClass().getName());
		Event event = Events.event(null, Events.DISCONNECT);
		if (channel.isConnected())
		{
			channel.write(event).addListener(ChannelFutureListener.CLOSE);
		}
		else
		{
			channel.close();
			LOG.trace("Unable to write the Event {} with type {} to socket",
					event, event.getType());
		}
	}