我应该在哪里捕获由FirestorePagingAdapter语言 - FirebaseUI-Android抛出的Inter



根据Firebase Crashlytics,我的一些用户正在经历崩溃:

Fatal Exception: io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.InterruptedException
at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:2)
at io.reactivex.rxjava3.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:54)
at io.reactivex.rxjava3.core.Single.subscribe(Single.java:8)
at io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:2)
at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:9)
at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:13)
at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
at com.google.android.gms.tasks.zzaa.zza(zzaa.java:2)
at com.google.android.gms.tasks.Tasks.await(Tasks.java:28)
at com.firebase.ui.firestore.paging.FirestorePagingSource.lambda$loadSingle$0(FirestorePagingSource.java)
at com.firebase.ui.firestore.paging.FirestorePagingSource.$r8$lambda$aRsAFsiduxRWbX-Rs8tsd39JsV0(FirestorePagingSource.java)
at com.firebase.ui.firestore.paging.FirestorePagingSource$$InternalSyntheticLambda$0$301762c7c2c4bb9cc6676b1600ffb92473af44448cde26854aae0b3e15f6f4f6$0.call$bridge(FirestorePagingSource.java:92)
at io.reactivex.rxjava3.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:16)
at io.reactivex.rxjava3.core.Single.subscribe(Single.java:8)
at io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:2)
at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:9)
at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:13)
at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)

我无法在我的终端上重现错误。然而,在错误信息链接的进一步阅读中,我可以阅读以下内容,这似乎与我的问题相关:

此外,一些第三方库/代码在得到时抛出被取消/处置调用中断,导致无法交付大多数时候都是例外。2.0.6的内部变化现在一致取消或处置订购/可弃用物品取消/处置导致中断的任务或工作线程目标线程)。

// in some library
try {
doSomethingBlockingly()
} catch (InterruptedException ex) {
// check if the interrupt is due to cancellation
// if so, no need to signal the InterruptedException
if (!disposable.isDisposed()) {
observer.onError(ex);
}
}

如果库/代码已经这样做了,则不可交付interrupteexceptions现在应该停止了。如果这个模式不是以前使用的,我们鼓励更新有问题的代码/库。

下面是我使用FirebaseUI-Android设置FirestorePagingAdapter的代码。如前所述,除了少数用户之外,它对所有用户都是完美的。

com.google.firebase.firestore.Query feedBaseQuery = firebaseHelper.getFeedBaseQuery();
PagingConfig config = new PagingConfig(10, 5, false);
FirestorePagingOptions<FeedObject> options = new FirestorePagingOptions.Builder<FeedObject>()
.setLifecycleOwner(mainActivity)
.setQuery(feedBaseQuery, config, FeedObject.class)
.build();
this.feedAdapter = new FirestoreFeedAdapter(mainActivity, options);
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(new LinearLayoutManager(mainActivity));
recyclerView.setAdapter(this.feedAdapter);

所以,我现在最好的猜测是,当从Firestore检索数据时,应用程序以某种方式被中断,这会产生一个从未被捕获的InterruptedException。我想我的问题是如果和在哪里我应该捕获InterruptedException?

当我用非常糟糕的网络或离线模式快速更改片段时,我有同样的错误,不是很好,但我在应用程序类上添加了这一点。它工作得很好…

RxJavaPlugins.setErrorHandler { e ->
if (e is UndeliverableException) {
Log.d(TAG, e.toString())
} else {
Thread.currentThread().also { thread ->
thread.uncaughtExceptionHandler.uncaughtException(thread, e)
}
}
}

相关内容

  • 没有找到相关文章

最新更新