Skip to content

Commit

Permalink
Use equals to check error code
Browse files Browse the repository at this point in the history
While the exception is never serialized and the error code object is a
singleton within a node it is still safer to check for equallity using
the equals method
  • Loading branch information
arhimondr authored and martint committed Jan 6, 2022
1 parent 78c494e commit f595687
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ private TaskFailureReporter(AtomicReference<DistributedStagesScheduler> distribu
@Override
public void onTaskFailed(TaskId taskId, Throwable failure)
{
if (failure instanceof TrinoException && ((TrinoException) failure).getErrorCode() == REMOTE_TASK_FAILED.toErrorCode()) {
if (failure instanceof TrinoException && REMOTE_TASK_FAILED.toErrorCode().equals(((TrinoException) failure).getErrorCode())) {
// This error indicates that a downstream task was trying to fetch results from an upstream task that is marked as failed
// Instead of failing a downstream task let the coordinator handle and report the failure of an upstream task to ensure correct error reporting
log.info("Task failure discovered while fetching task results: %s", taskId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public synchronized void taskFailed(TaskId taskId, Throwable t)
}
checkState(activeTasks.contains(taskId), "taskId not registered: %s", taskId);

if (t instanceof TrinoException && ((TrinoException) t).getErrorCode() == REMOTE_TASK_FAILED.toErrorCode()) {
if (t instanceof TrinoException && REMOTE_TASK_FAILED.toErrorCode().equals(((TrinoException) t).getErrorCode())) {
// let coordinator handle this
return;
}
Expand Down

0 comments on commit f595687

Please sign in to comment.