@Test public void testResponseNotLeakedIfCancelled_completable() { CompletableFutureBodyCallAdapter<String> adapter = new CompletableFutureBodyCallAdapter<>(String.class); CompletableFuture<String> result = adapter.adapt(call); verify(call).enqueue(callbackCaptor.capture()); Callback<String> callback = callbackCaptor.getValue(); result.cancel(true); callback.onResponse(call, response); verify(response.raw().body()).close(); }
private static void close(Response<?> response) { ResponseBody body = response.raw().body(); if (body != null) { body.close(); } }
AsyncSerializableErrorCallAdapterFactory extends CallAdapter.Factory { private static void close(Response<?> response) { ResponseBody body = response.raw().body(); if (body != null) { body.close(); } } }
AsyncSerializableErrorCallAdapterFactory extends CallAdapter.Factory { private static void close(Response<?> response) { ResponseBody body = response.raw().body(); if (body != null) { body.close(); } } private  AsyncSerializableErrorCallAdapterFactory(); }
AsyncSerializableErrorCallAdapterFactory extends CallAdapter.Factory { private static void close(Response<?> response) { ResponseBody body = response.raw().body(); if (body != null) { body.close(); } } private  AsyncSerializableErrorCallAdapterFactory(); @Override CallAdapter<?, ?> get(Type returnType, Annotation[] _annotations, Retrofit _retrofit); }
AsyncSerializableErrorCallAdapterFactory extends CallAdapter.Factory { private static void close(Response<?> response) { ResponseBody body = response.raw().body(); if (body != null) { body.close(); } } private  AsyncSerializableErrorCallAdapterFactory(); @Override CallAdapter<?, ?> get(Type returnType, Annotation[] _annotations, Retrofit _retrofit);  }