if (in == null) {
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
} catch (FileNotFoundException e) {
if (isRemoved) {
throw new HiveSQLException("The operation has been closed and its log file " +
file.getAbsolutePath() + " has been removed.", e);
} else {
throw new HiveSQLException("Operation Log file " + file.getAbsolutePath() +
" is not found.", e);
}
}
}
List<String> logs = new ArrayList<String>();
String line = "";
// if nLines <= 0, read all lines in log file.
for (int i = 0; i < nLines || nLines <= 0; i++) {
try {
line = in.readLine();
if (line == null) {
break;
} else {
logs.add(line);
}
} catch (IOException e) {
if (isRemoved) {
throw new HiveSQLException("The operation has been closed and its log file " +
file.getAbsolutePath() + " has been removed.", e);
} else {
throw new HiveSQLException("Reading operation log file encountered an exception: ", e);
}
}
}
return logs;
}