Skip to content

Commit

Permalink
added oncancel to handle exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-jalgaonkar committed Jun 26, 2024
1 parent 878d515 commit c267fd0
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ public void onMessage(ReqT request) {
detachContext(contextWithHeaders, previous); // detach headers from gRPC context
}
}

@Override
public void onCancel() {
Context previous = attachContext(contextWithHeaders); // attaching headers to gRPC context
try {
super.onCancel();
} catch (RuntimeException ex) {
handleException(call, ex);
} finally {
detachContext(contextWithHeaders, previous); // detach headers from gRPC context
}
}
};
}

Expand Down

0 comments on commit c267fd0

Please sign in to comment.