Program: 25241
Project: 25241
Buggy source:
@Override public void updateStatus(QueryContext context) throws LensException {
  log.debug("String_Node_Str",context.getQueryHandle());
  if (context.getDriverStatus().isFinished()) {
    return;
  }
  OperationHandle hiveHandle=getHiveHandle(context.getQueryHandle());
  ByteArrayInputStream in=null;
  try {
    log.debug("String_Node_Str",hiveHandle);
    fetchLogs(hiveHandle);
    OperationStatus opStatus=getClient().getOperationStatus(hiveHandle);
    log.debug("String_Node_Str",hiveHandle,opStatus.getState().name());
switch (opStatus.getState()) {
case CANCELED:
      context.getDriverStatus().setState(DriverQueryState.CANCELED);
    context.getDriverStatus().setStatusMessage("String_Node_Str");
  break;
case CLOSED:
context.getDriverStatus().setState(DriverQueryState.CLOSED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case ERROR:
context.getDriverStatus().setState(DriverQueryState.FAILED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
context.getDriverStatus().setErrorMessage("String_Node_Str" + opStatus.getOperationException().getErrorCode() + "String_Node_Str"+ opStatus.getOperationException().getMessage());
break;
case FINISHED:
context.getDriverStatus().setState(DriverQueryState.SUCCESSFUL);
context.getDriverStatus().setStatusMessage("String_Node_Str");
context.getDriverStatus().setResultSetAvailable(hiveHandle.hasResultSet());
break;
case INITIALIZED:
context.getDriverStatus().setState(DriverQueryState.INITIALIZED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case RUNNING:
context.getDriverStatus().setState(DriverQueryState.RUNNING);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case PENDING:
context.getDriverStatus().setState(DriverQueryState.PENDING);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case UNKNOWN:
default :
throw new LensException("String_Node_Str");
}
float progress=0f;
String jsonTaskStatus=opStatus.getTaskStatus();
String errorMsg=null;
if (StringUtils.isNotBlank(jsonTaskStatus)) {
ObjectMapper mapper=new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
in=new ByteArrayInputStream(jsonTaskStatus.getBytes("String_Node_Str"));
List<TaskDisplay> taskStatuses=mapper.readValue(in,new TypeReference<List<TaskDisplay>>(){
}
);
int completedTasks=0;
StringBuilder errorMessage=new StringBuilder();
for (TaskDisplay taskStat : taskStatuses) {
Task.TaskState tstate=taskStat.taskState;
if (tstate == Task.TaskState.FINISHED) {
completedTasks++;
}
if (taskStat.getErrorMsg() != null) {
appendTaskIds(errorMessage,taskStat);
errorMessage.append("String_Node_Str");
}
}
progress=taskStatuses.size() == 0 ? 0 : (float)completedTasks / taskStatuses.size();
errorMsg=errorMessage.toString();
}
 else {
log.warn("String_Node_Str");
}
String error=null;
if (StringUtils.isNotBlank(errorMsg)) {
error=errorMsg;
}
 else if (opStatus.getState().equals(OperationState.ERROR)) {
error=context.getDriverStatus().getStatusMessage();
}
context.getDriverStatus().setErrorMessage(error);
context.getDriverStatus().setProgressMessage(jsonTaskStatus);
context.getDriverStatus().setProgress(progress);
context.getDriverStatus().setDriverStartTime(opStatus.getOperationStarted());
context.getDriverStatus().setDriverFinishTime(opStatus.getOperationCompleted());
}
 catch (Exception e) {
log.error("String_Node_Str",e);
handleHiveServerError(context,e);
throw new LensException("String_Node_Str",e);
}
 finally {
if (in != null) {
try {
in.close();
}
 catch (IOException e) {
log.error("String_Node_Str",e);
}
}
}
}

Fixed version (ground truth):
@Override public void updateStatus(QueryContext context) throws LensException {
  log.debug("String_Node_Str",context.getQueryHandle());
  if (context.getDriverStatus().isFinished()) {
    return;
  }
  OperationHandle hiveHandle=getHiveHandle(context.getQueryHandle());
  ByteArrayInputStream in=null;
  try {
    log.debug("String_Node_Str",hiveHandle);
    fetchLogs(hiveHandle);
    OperationStatus opStatus=getClient().getOperationStatus(hiveHandle);
    log.debug("String_Node_Str",hiveHandle,opStatus.getState().name());
switch (opStatus.getState()) {
case CANCELED:
      context.getDriverStatus().setState(DriverQueryState.CANCELED);
    context.getDriverStatus().setStatusMessage("String_Node_Str");
  break;
case CLOSED:
context.getDriverStatus().setState(DriverQueryState.CLOSED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case ERROR:
context.getDriverStatus().setState(DriverQueryState.FAILED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
context.getDriverStatus().setErrorMessage("String_Node_Str" + opStatus.getOperationException().getErrorCode() + "String_Node_Str"+ opStatus.getOperationException().getMessage());
break;
case FINISHED:
context.getDriverStatus().setState(DriverQueryState.SUCCESSFUL);
context.getDriverStatus().setStatusMessage("String_Node_Str");
context.getDriverStatus().setResultSetAvailable(hiveHandle.hasResultSet());
break;
case INITIALIZED:
context.getDriverStatus().setState(DriverQueryState.INITIALIZED);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case RUNNING:
context.getDriverStatus().setState(DriverQueryState.RUNNING);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case PENDING:
context.getDriverStatus().setState(DriverQueryState.PENDING);
context.getDriverStatus().setStatusMessage("String_Node_Str");
break;
case UNKNOWN:
default :
throw new LensException("String_Node_Str");
}
float progress=0f;
String jsonTaskStatus=opStatus.getTaskStatus();
String errorMsg=null;
if (StringUtils.isNotBlank(jsonTaskStatus)) {
ObjectMapper mapper=new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
in=new ByteArrayInputStream(jsonTaskStatus.getBytes("String_Node_Str"));
List<TaskDisplay> taskStatuses=mapper.readValue(in,new TypeReference<List<TaskDisplay>>(){
}
);
int completedTasks=0;
StringBuilder errorMessage=new StringBuilder();
for (TaskDisplay taskStat : taskStatuses) {
Task.TaskState tstate=taskStat.taskState;
if (tstate == Task.TaskState.FINISHED) {
completedTasks++;
}
if ((taskStat.getReturnValue() != null && taskStat.getReturnValue() != 0) || taskStat.getErrorMsg() != null) {
appendTaskIds(errorMessage,taskStat);
errorMessage.append("String_Node_Str");
}
}
progress=taskStatuses.size() == 0 ? 0 : (float)completedTasks / taskStatuses.size();
errorMsg=errorMessage.toString();
}
 else {
log.warn("String_Node_Str");
}
String error=null;
if (StringUtils.isNotBlank(errorMsg)) {
error=errorMsg;
}
 else if (opStatus.getState().equals(OperationState.ERROR)) {
error=context.getDriverStatus().getStatusMessage();
}
context.getDriverStatus().setErrorMessage(error);
context.getDriverStatus().setProgressMessage(jsonTaskStatus);
context.getDriverStatus().setProgress(progress);
context.getDriverStatus().setDriverStartTime(opStatus.getOperationStarted());
context.getDriverStatus().setDriverFinishTime(opStatus.getOperationCompleted());
}
 catch (Exception e) {
log.error("String_Node_Str",e);
handleHiveServerError(context,e);
throw new LensException("String_Node_Str",e);
}
 finally {
if (in != null) {
try {
in.close();
}
 catch (IOException e) {
log.error("String_Node_Str",e);
}
}
}
}