0

我有异常的问题

getCurrentUpdateDateFromStorage() java.util.NoSuchElementException:源发布者为空

该代码工作了很长时间,今天我遇到了这个问题。

  private fun getCurrentUpdateDateFromStorage(sentDate: Date) {
    LogMgr.d(TAG, "getCurrentUpdateDateFromStorage()")
    val flotaUserId = getCurrentFlotaUserId()

    if (flotaUserId > 0) {
        compositeDisposable.add(wfmStorageDomain.getLastUpdateDate(flotaUserId)
                .subscribe(
                        { lastLocalUpdateDate ->
                            LogMgr.d(TAG, "lastLocalUpdateDate: $lastLocalUpdateDate, time: " + (lastLocalUpdateDate?.time
                                    ?: "null"))
                            if (lastLocalUpdateDate == null || lastLocalUpdateDate.time < sentDate.time) {
                                LogMgr.d(TAG, "update needs to be done")
                                updateEventPlannersFromServer(lastLocalUpdateDate)
                            } else {
                                LogMgr.d(TAG, "update not necessary, or invalid data -> localDate:$lastLocalUpdateDate : sentDate:$sentDate")
                            }
                        },
                        { error ->
                            LogMgr.e(TAG, "getCurrentUpdateDateFromStorage() $error")
                        }))
    } else {
        LogMgr.e(TAG, "getCurrentUpdateDateFromStorage() Invalid flotaUserId:$flotaUserId")
    }
}

==================

   override fun getLastUpdateDate(flotaUserId: Int): Single<Date> {
    LogMgr.d(TAG, "getLastUpdateDate(): $flotaUserId")
    return Single.fromPublisher({ subscriber ->
        RXSQLite.rx(
                SQLite.select().from(EventPlanner::class.java)
                        .orderBy(EventPlanner_Table.sentDate, false))
                .queryList()
                .subscribeOn(getSubscriptionScheduler())
                .subscribe({ eventPlanner ->
                    LogMgr.d(TAG, "getLastUpdateDate() $eventPlanner")

                    if (eventPlanner.isEmpty()) {
                        subscriber.onNext(Date(0L))
                    } else {
                        subscriber.onNext(eventPlanner[0].sentDate)
                    }
                    subscriber.onComplete()
                }, { error ->
                    LogMgr.e(TAG, "getLastUpdateDate()", error)
                    subscriber.onError(error)
                })
    })
}

知道如何解决吗? 感谢您的任何建议和提示。

编辑:堆栈跟踪

java.util.NoSuchElementException: The source Publisher is empty
    at io.reactivex.internal.operators.single.SingleFromPublisher$ToSingleObserver.onComplete(SingleFromPublisher.java:99)
    at com.fs.wfm.storage.dbflow.DBFlowWfmStorageRepo$getLastUpdateDate$1$1.accept(DBFlowWfmStorageRepo.kt:211)
    at com.fs.wfm.storage.dbflow.DBFlowWfmStorageRepo$getLastUpdateDate$1$1.accept(DBFlowWfmStorageRepo.kt:22)
    at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:63)
    at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.onSuccess(SingleSubscribeOn.java:68)
    at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:56)
    at io.reactivex.Single.subscribe(Single.java:3310)
    at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
    at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:579)
    at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
    at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
    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:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)

在此处输入图像描述 在此处输入图像描述

4

0 回答 0