private List<String> readResults(final int nLines) throws SQLException {
      final List<String> logs = new ArrayList<String>();
      int readCount = (nLines <= 0) ? Integer.MAX_VALUE : nLines;

      if (in == null) {
        try {
          in = new BufferedReader(new InputStreamReader(
              new FileInputStream(file), StandardCharsets.UTF_8));
          if (isShortLogs) {
            // Adding name of the log file in an extra log line, so it is easier to find
            // the original if there is a test error
            logs.add("Reading log file: " + file);
            readCount--;
          }
        } catch (FileNotFoundException e) {
          return Collections.emptyList();
        }
      }

      try {
        while (readCount > 0) {
          final String line = in.readLine();
          readCount--;
          final boolean added = CollectionUtils.addIgnoreNull(logs, line);
          if (!added) {
            break;
          }
        }
      } catch (IOException e) {
        if (isRemoved) {
          throw new SQLException("The operation has been closed and its log file " +
            file.getAbsolutePath() + " will be removed", e);
        } else {
          throw new SQLException("Reading operation log file encountered an exception", e);
        }
      }
      return logs;
    }
Close the logs, and remove them if specified.
@param removeLog If true, remove the log file
ql/src/java/org/apache/hadoop/hive/ql/session/OperationLog.java