diff --git service/src/java/org/apache/hive/service/cli/operation/OperationManager.java service/src/java/org/apache/hive/service/cli/operation/OperationManager.java index 96c01de40fa581f1583fc3f9a93a2c71355ebc04..b93ec10724ede4f63add0900dd52e2d5ce498394 100644 --- service/src/java/org/apache/hive/service/cli/operation/OperationManager.java +++ service/src/java/org/apache/hive/service/cli/operation/OperationManager.java @@ -182,22 +182,6 @@ private Operation getOperationInternal(OperationHandle operationHandle) { return handleToOperation.get(operationHandle); } - private Operation removeTimedOutOperation(OperationHandle operationHandle) { - Operation operation = handleToOperation.get(operationHandle); - if (operation != null && operation.isTimedOut(System.currentTimeMillis())) { - handleToOperation.remove(operationHandle, operation); - synchronized (webuiLock) { - String opKey = operationHandle.getHandleIdentifier().toString(); - SQLOperationDisplay display = liveSqlOperations.remove(opKey); - if (historicSqlOperations != null) { - historicSqlOperations.put(opKey, display); - } - } - return operation; - } - return null; - } - private void addOperation(Operation operation) { handleToOperation.put(operation.getHandle(), operation); if (operation instanceof SQLOperation) { @@ -209,15 +193,38 @@ private void addOperation(Operation operation) { } private Operation removeOperation(OperationHandle opHandle) { - Operation result = handleToOperation.remove(opHandle); + Operation operation = handleToOperation.remove(opHandle); + if (operation instanceof SQLOperation) { + removeSaveSqlOperationDisplay(opHandle); + } + return operation; + } + + private Operation removeTimedOutOperation(OperationHandle operationHandle) { + Operation operation = handleToOperation.get(operationHandle); + if (operation != null && operation.isTimedOut(System.currentTimeMillis())) { + handleToOperation.remove(operationHandle, operation); + if (operation instanceof SQLOperation) { + removeSaveSqlOperationDisplay(operationHandle); + } + return operation; + } + return null; + } + + private void removeSaveSqlOperationDisplay(OperationHandle operationHandle) { synchronized (webuiLock) { - String opKey = opHandle.getHandleIdentifier().toString(); + String opKey = operationHandle.getHandleIdentifier().toString(); + // remove from list of live operations SQLOperationDisplay display = liveSqlOperations.remove(opKey); - if (historicSqlOperations != null) { + if (display == null) { + LOG.debug("Unexpected display object value of null for operation {}", + opKey); + } else if (historicSqlOperations != null) { + // add to list of saved historic operations historicSqlOperations.put(opKey, display); } } - return result; } public OperationStatus getOperationStatus(OperationHandle opHandle)