gpt4 book ai didi

android - 重试获取数据 : rx. exceptions.MissingBackpressureException

转载 作者:行者123 更新时间:2023-11-29 20:08:58 24 4
gpt4 key购买 nike

我在生产发布(市场构建)时遇到了这个崩溃。这么多用户受到这次崩溃的影响,但我无法重现。

这是堆栈跟踪:

Fatal Exception: java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:60)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Caused by rx.exceptions.OnErrorNotImplementedException
at rx.Observable$31.onError(Observable.java:7280)
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
at rx.observers.SerializedObserver.onError(SerializedObserver.java:122)
at rx.observers.SerializedSubscriber.onError(SerializedSubscriber.java:79)
at rx.android.app.OperatorConditionalBinding$1.onError(OperatorConditionalBinding.java:69)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:183)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:159)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Caused by rx.exceptions.MissingBackpressureException
at rx.internal.util.RxRingBuffer.onNext(RxRingBuffer.java:349)
at rx.internal.operators.OperatorZip$Zip$InnerSubscriber.onNext(OperatorZip.java:330)
at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
at com.opensooq.OpenSooq.ui.BaseActivity$2.onClick(BaseActivity.java:562)
at android.view.View.performClick(View.java:5156)
at android.view.View$PerformClick.run(View.java:20755)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

这是我的代码:

public static final Func1 RETRY_CONDITION = new Func1<Observable<? extends Throwable>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Throwable> observable) {
return observable.zipWith(NO_INTERENT_CLICKED_EVENT, new Func2<Throwable, Object, Object>() {
@Override
public Object call(Throwable throwable, Object o) {
return throwable;
}
});
}
};

public static final PublishSubject<Object> NO_INTERENT_CLICKED_EVENT = PublishSubject.create();

noInternetView.findViewById(R.id.bRetry).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
noInternetView.findViewById(R.id.noInternetLoading).setVisibility(View.VISIBLE);
noInternetView.findViewById(R.id.llBody).setVisibility(View.GONE);
NO_INTERENT_CLICKED_EVENT.onNext(new Object());
}
});

调用登录可观察:

  bindLifecycle(loginObservable
.observeOn(AndroidSchedulers.mainThread())
.doOnError(new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
if (throwable instanceof RetrofitError) {
toggleNoInternetView(true);
}
hideLoader();
}
})
.doOnNext(new Action1<LoginResult>() {
@Override
public void call(LoginResult loginResult) {
// Handle success
}
})
.doOnCompleted(new Action0() {
@Override
public void call() {
hideLoader();
toggleNoInternetView(false);
}
})
.retryWhen(BaseActivity.RETRY_CONDITION), LifecycleEvent.DESTROY)
.subscribe();

我的代码在互联网连接丢失时重试获取数据。

请帮助解决此问题。

最佳答案

有两种失败需要考虑。第一个是 OnErrorNotImplementedException,这意味着您使用 subscribe(Action1) 而不是 subscribe(Action1, Action1) 并且该异常无处可去。

第二个失败是 zip 中的缓冲区溢出,可能是因为您没有在其输入上使用 onBackpressureBufferonBackpressureDrop。由于您的示例中没有 zip,我不能说为什么它不能使用点击事件。也许 zip 的其他来源或 zip 的下游更慢。也许您也将事件推送到其他地方的 NO_INTERENT_CLICKED_EVENT

关于android - 重试获取数据 : rx. exceptions.MissingBackpressureException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35296033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com