Commit 0a7e1461 authored by Gabriele Civitarese's avatar Gabriele Civitarese

example of exception handling

parent c67a6f6d
......@@ -48,8 +48,19 @@ public class ChatServiceImpl extends ChatServiceImplBase {
//we exclude the one which is sending the message
if(!observer.equals(responseObserver))
//we simply forward the message
observer.onNext(ChatMessage.newBuilder().setMessage(message).setFrom(from).build());
try {
observer.onNext(ChatMessage.newBuilder().setMessage(message).setFrom(from).build());
}
catch(io.grpc.StatusRuntimeException e){
//peer no longer available
synchronized (observers){
observers.remove(responseObserver);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment