Merge pull request #829 from Endeavour233/avoid-leak-response-body

Opti: avoid leaking response body when request is cancelled
This commit is contained in:
Gregory K 2024-04-21 18:11:02 +03:00 committed by GitHub
commit b0c77d42c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -113,8 +113,10 @@ public class MastodonAPIController{
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException{
if(req.canceled)
if(req.canceled){
response.close();
return;
}
if(BuildConfig.DEBUG)
Log.d(TAG, logTag(session)+hreq+" received response: "+response);
synchronized(req){

View File

@ -316,8 +316,10 @@ abstract class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInsta
loadingInstanceRedirectRequest=null;
loadingInstanceDomain=null;
Activity a=getActivity();
if(a==null)
if(a==null) {
response.close();
return;
}
try(response){
if(!response.isSuccessful()){
a.runOnUiThread(()->{