Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

**Fixed**

- Nothing yet!
- Propagate timeouts and other external cancels in retrofit-adapter for rxjava2 and rxjava3


## [3.0.0] - 2025-05-15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onResponse(Call<T> call, Response<T> response) {

@Override
public void onFailure(Call<T> call, Throwable t) {
if (call.isCanceled()) return;
if (disposed) return;

try {
observer.onError(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.TestObserver;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockWebServer;
Expand Down Expand Up @@ -79,4 +84,14 @@ public void cancelDoesNotDispose() {
calls.get(0).cancel();
assertFalse(disposable.isDisposed());
}

@Test
public void cancelSetsError() throws InterruptedException {
TestObserver<?> testObserver = service.go().test();
List<Call> calls = client.dispatcher().runningCalls();
assertEquals(1, calls.size());
calls.get(0).cancel();
testObserver.await(10, TimeUnit.SECONDS);
testObserver.assertError(e -> e instanceof IOException && "Canceled".equals(e.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onResponse(Call<T> call, Response<T> response) {

@Override
public void onFailure(Call<T> call, Throwable t) {
if (call.isCanceled()) return;
if (disposed) return;

try {
observer.onError(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.observers.TestObserver;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockWebServer;
Expand Down Expand Up @@ -79,4 +84,14 @@ public void cancelDoesNotDispose() {
calls.get(0).cancel();
assertFalse(disposable.isDisposed());
}

@Test
public void cancelSetsError() throws InterruptedException {
TestObserver<?> testObserver = service.go().test();
List<Call> calls = client.dispatcher().runningCalls();
assertEquals(1, calls.size());
calls.get(0).cancel();
testObserver.await(10, TimeUnit.SECONDS);
testObserver.assertError(e -> e instanceof IOException && "Canceled".equals(e.getMessage()));
}
}