未验证 提交 5c2f505a 编写于 作者: J Jake Wharton 提交者: GitHub

Merge pull request #2721 from adriancole/observableAssembly

Makes sure observable assembly hooks are called
......@@ -18,6 +18,7 @@ package retrofit2.adapter.rxjava2;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.plugins.RxJavaPlugins;
import java.lang.reflect.Type;
import javax.annotation.Nullable;
import retrofit2.Call;
......@@ -83,6 +84,6 @@ final class RxJava2CallAdapter<R> implements CallAdapter<R, Object> {
if (isCompletable) {
return observable.ignoreElements();
}
return observable;
return RxJavaPlugins.onAssembly(observable);
}
}
......@@ -16,6 +16,8 @@
package retrofit2.adapter.rxjava2;
import io.reactivex.Observable;
import io.reactivex.functions.Function;
import io.reactivex.plugins.RxJavaPlugins;
import java.io.IOException;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
......@@ -133,4 +135,18 @@ public final class ObservableTest {
assertThat(result.error()).isInstanceOf(IOException.class);
observer.assertComplete();
}
@Test public void observableAssembly() {
try {
final Observable<String> justMe = Observable.just("me");
RxJavaPlugins.setOnObservableAssembly(new Function<Observable, Observable>() {
@Override public Observable apply(Observable f) {
return justMe;
}
});
assertThat(service.body()).isEqualTo(justMe);
} finally {
RxJavaPlugins.reset();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册