Skip to content

Commit 05b0470

Browse files
authored
Tweak session pulse to account for gRPC exceptions (#237)
## What is the goal of this PR? Session pulses to an unavailable server now closes the session instead of throwing an unhandled exception. ## What are the changes implemented in this PR? Catch `StatusRuntimeException` in session pulse and treat it as session being closed
1 parent 050b99f commit 05b0470

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rpc/RPCSession.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,14 @@ public String database() {
118118
Channel channel() { return channel; }
119119

120120
public void pulse() {
121-
final SessionProto.Session.Pulse.Res res = blockingGrpcStub.sessionPulse(
122-
SessionProto.Session.Pulse.Req.newBuilder().setSessionId(sessionId).build());
123-
124-
if (!res.getAlive()) {
121+
boolean alive;
122+
try {
123+
alive = blockingGrpcStub.sessionPulse(
124+
SessionProto.Session.Pulse.Req.newBuilder().setSessionId(sessionId).build()).getAlive();
125+
} catch (StatusRuntimeException exception) {
126+
alive = false;
127+
}
128+
if (!alive) {
125129
isOpen.set(false);
126130
pulse.cancel();
127131
}

0 commit comments

Comments
 (0)