Commit bf51bde0 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Closing response body from websocket frames if any to avoid resource leaks

parent 6dc6e403
package chat.rocket.android_ddp.rx; package chat.rocket.android_ddp.rx;
import static android.R.attr.resizeable;
import static android.R.attr.type; import static android.R.attr.type;
import chat.rocket.android.log.RCLog; import chat.rocket.android.log.RCLog;
...@@ -28,6 +29,9 @@ public class RxWebSocketCallback { ...@@ -28,6 +29,9 @@ public class RxWebSocketCallback {
public Open(WebSocket websocket, Response response) { public Open(WebSocket websocket, Response response) {
super("Open", websocket); super("Open", websocket);
this.response = response; this.response = response;
if (response != null && response.body() != null) {
this.response.body().close();
}
} }
} }
...@@ -37,6 +41,9 @@ public class RxWebSocketCallback { ...@@ -37,6 +41,9 @@ public class RxWebSocketCallback {
public Failure(WebSocket websocket, Throwable err, Response response) { public Failure(WebSocket websocket, Throwable err, Response response) {
super("Failure", websocket); super("Failure", websocket);
this.response = response; this.response = response;
if (response != null && response.body() != null) {
this.response.body().close();
}
} }
@Override @Override
......
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