Commit e8cdd16d authored by Leonardo Aramaki's avatar Leonardo Aramaki

Close the socket if we get an error because MethodCallHelper class keep a...

Close the socket if we get an error because MethodCallHelper class keep a reference to socket and it has objects spread all over the place. Thus this may cause inconsistencies that are hard to keep track, so it's safer to close the socket so that the websocket thread will know and try to reconnect.
parent db0b3707
......@@ -82,6 +82,10 @@ public class MethodCallHelper {
return task.continueWithTask(_task -> {
if (_task.isFaulted()) {
Exception exception = _task.getError();
// If wet get any error, close the socket to let the RocketChatWebSocketThread aware of it.
// FIXME: when rewriting the network layer we should get rid of this MethodCallHelper
// monolith concept. It decouples a lot the socket from the rest of the app.
ddpClientRef.get().close();
if (exception instanceof MethodCall.Error) {
String errMessageJson = exception.getMessage();
if (TextUtils.isEmpty(errMessageJson)) {
......@@ -93,7 +97,6 @@ public class MethodCallHelper {
if (TwoStepAuthException.TYPE.equals(errType)) {
return Task.forError(new TwoStepAuthException(errMessage));
}
return Task.forError(new Exception(errMessage));
} else if (exception instanceof DDPClientCallback.RPC.Error) {
String errMessage = ((DDPClientCallback.RPC.Error) exception).error.getString("message");
......
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