HIVE-13099: Non-SQLOperations lead to Web UI NPE (Mohit via Jimmy)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ac9c5991 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ac9c5991 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ac9c5991 Branch: refs/heads/llap Commit: ac9c5991b5bf8184319657315638af73b22b1c02 Parents: 305c2f6 Author: Jimmy Xiang <jxi...@apache.org> Authored: Mon Feb 22 08:18:45 2016 -0800 Committer: Jimmy Xiang <jxi...@apache.org> Committed: Mon Feb 22 08:18:45 2016 -0800 ---------------------------------------------------------------------- .../service/cli/operation/OperationManager.java | 47 +++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/ac9c5991/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java b/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java index 1b8aca9..56a9c18 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java +++ b/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java @@ -181,22 +181,6 @@ public class OperationManager extends AbstractService { 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) { @@ -208,15 +192,38 @@ public class OperationManager extends AbstractService { } 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)