Skip to content

Commit

Permalink
Capture exceptions in async ExecuteStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed May 26, 2021
1 parent c8b2ec4 commit 8031528
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ class ExecuteStatement(
isComplete = true
remoteState match {
case INITIALIZED_STATE | PENDING_STATE | RUNNING_STATE =>
isComplete = false
statusResp = client.GetOperationStatus(statusReq)
try {
statusResp = client.GetOperationStatus(statusReq)
isComplete = false
} catch onError(rethrow = false)

case FINISHED_STATE =>
setState(OperationState.FINISHED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ abstract class KyuubiOperation(
ThriftUtils.verifyTStatus(tStatus)
}

protected def onError(action: String = "operating"): PartialFunction[Throwable, Unit] = {
protected def onError(action: String = "operating",
rethrow: Boolean = true): PartialFunction[Throwable, Unit] = {
case e: Throwable =>
state.synchronized {
if (isTerminalState(state)) {
Expand All @@ -66,7 +67,9 @@ abstract class KyuubiOperation(
KyuubiSQLException(s"Error $action $opType: ${e.getMessage}", e)
}
setOperationException(ke)
throw ke
if (rethrow) {
throw ke
}
}
}
}
Expand Down

0 comments on commit 8031528

Please sign in to comment.