code: @Override
      public void setWriteTarget(MessageWriteTarget writeTarget) {
          checkArgument(writeTarget != null);
          lock.lock();
          boolean closeNow = false;
          try {
              checkArgument(this.writeTarget == null);
              closeNow = closePending;
              this.writeTarget = writeTarget;
          } finally {
              lock.unlock();
          }
          if (closeNow)
              writeTarget.closeConnection();
      }
docs: Sets the {@link MessageWriteTarget} used to write messages to the peer. This should almost never be called, it is
  called automatically by {@link NioClient} or
  {@link NioClientManager} once the socket finishes initialization.