I've been getting this error:
A connection to ****** was leaked. Did you forget to close a response body?
So I went on and close the responses I get.
response.body().close()
Problem is if the response.body() is already converted to a custom class, there's no close method available. Also I tried calling raw and gives me an exception:
fetchSomething.enqueue(new Callback<SomethingClass>() {
@Override
public void onResponse(Call<SomethingClass> call, Response<SomethingClass> response) {
//Closes the response body
response.raw().body().close(); //<--- gives illegalStateException
}
@Override
public void onFailure(Call<SomethingClass> call, Throwable t) {
}
});
}
How do I close it?