protected void failOnInterruption(IOException io) throws IOException {
    try {
      if (Thread.interrupted()) {
        // Either we were interrupted by one of:
        // 1. handleEvent(), in which case there is a reader (error) event waiting for us in the queue
        // 2. Some other unrelated cause which interrupted us, in which case there may not be a reader event coming.
        // Either way we should not try to block trying to read the reader events queue.
        if (readerEvents.isEmpty()) {
          // Case 2.
          throw io;
        } else {
          // Case 1. Fail the reader, sending back the error we received from the reader event.
          ReaderEvent event = getReaderEvent();
          switch (event.getEventType()) {
            case ERROR:
              throw new IOException("Received reader event error: " + event.getMessage(), io);
            default:
              throw new IOException("Got reader event type " + event.getEventType()
                  + ", expected error event", io);
          }
        }
      } else {
        // If we weren't interrupted, just propagate the error
        throw io;
      }
    } finally {
      // The external client handling umbilical responses and the connection to read the incoming
      // data are not coupled. Calling close() here to make sure an error in one will cause the
      // other to be closed as well.
      try {
        close();
      } catch (Exception err) {
        // Don't propagate errors from close() since this will lose the original error above.
        LOG.error("Closing RecordReader due to error and hit another error during close()", err);
      }
    }
  }
Base LLAP RecordReader to handle receiving of the data from the LLAP daemon.
llap-client/src/java/org/apache/hadoop/hive/llap/LlapBaseRecordReader.java