HIVE-15563: Ignore Illegal Operation state transition exception in SQLOperation.runQuery to expose real exception (Zhihai Xu via Jimmy Xiang)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/cb771bb1 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/cb771bb1 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/cb771bb1 Branch: refs/heads/master Commit: cb771bb194ad31e7b9a867086119f3d382ecb22d Parents: 1a71607 Author: Zhihai Xu <zhihaixu2...@gmail.com> Authored: Wed Jan 11 08:06:29 2017 -0800 Committer: Jimmy Xiang <jxi...@apache.org> Committed: Wed Jan 11 08:06:29 2017 -0800 ---------------------------------------------------------------------- .../hive/service/cli/operation/SQLOperation.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/cb771bb1/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java index 80a615d..e9f619a 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java @@ -249,7 +249,7 @@ public class SQLOperation extends ExecuteStatementOperation { if (0 != response.getResponseCode()) { throw toSQLException("Error while processing statement", response); } - } catch (HiveSQLException e) { + } catch (Throwable e) { /** * If the operation was cancelled by another thread, or the execution timed out, Driver#run * may return a non-zero response code. We will simply return if the operation state is @@ -258,14 +258,15 @@ public class SQLOperation extends ExecuteStatementOperation { if ((getStatus().getState() == OperationState.CANCELED) || (getStatus().getState() == OperationState.TIMEDOUT) || (getStatus().getState() == OperationState.CLOSED)) { + LOG.warn("Ignore exception in terminal state", e); return; - } else { - setState(OperationState.ERROR); - throw e; } - } catch (Throwable e) { setState(OperationState.ERROR); - throw new HiveSQLException("Error running query: " + e.toString(), e); + if (e instanceof HiveSQLException) { + throw (HiveSQLException) e; + } else { + throw new HiveSQLException("Error running query: " + e.toString(), e); + } } setState(OperationState.FINISHED); }