FirebaseDatabase RxJava2扩展中的StackOverflow异常

时间:2017-08-17 21:50:59

标签: android firebase firebase-realtime-database rx-java rx-java2

我正在为FirebaseDatabase编写一个RxJava扩展,但遗憾的是每当我运行此代码时,我会在注释的代码中指定的行处获得stackOverflow异常。请提前帮助,并提前致谢。

Flowable<Success> addDish(Dish dish, boolean upload) {
    DatabaseReference newDishRef = databaseReference.push();
    dish.setId(newDishRef.getKey());
    return Flowable.create( 
            e -> newDishRef.setValue(dish) // StackOverFlow Exception here
                    .addOnSuccessListener(
                            aVoid -> e.onNext(upload ? new Success(dish.getMenuImage()) : new Success()))
                    .addOnCompleteListener(task -> e.onComplete()).addOnFailureListener(e::onError),
            BackpressureStrategy.BUFFER);
}

堆栈追踪:

io.reactivex.exceptions.UndeliverableException: 

java.lang.StackOverflowError: stack size 1036KB
08-17 17:59:07.207 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:349)
08-17 17:59:07.207 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:64)
08-17 17:59:07.207 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err:     at java.lang.Thread.run(Thread.java:818)
08-17 17:59:07.208 12744-13103/com.nowait.menu.admin W/System.err: Caused by: java.lang.StackOverflowError: stack size 1036KB
08-17 17:59:07.223 12744-13103/com.nowait.menu.admin W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
08-17 17:59:07.223 12744-13103/com.nowait.menu.admin W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
08-17 17:59:07.223 12744-13103/com.nowait.menu.admin W/System.err:     at com.google.android.gms.internal.zh.zzas(Unknown Source)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at com.google.android.gms.internal.zg.zzan(Unknown Source) //  there was a million of those
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at com.nowait.menu.admin.screens.menu.detail.EditDishVM.lambda$addDish$5(EditDishVM.java:67)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at com.nowait.menu.admin.screens.menu.detail.EditDishVM$$Lambda$5.subscribe(Unknown Source)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12986)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12932)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableScalarXMap$ScalarXMapFlowable.subscribeActual(FlowableScalarXMap.java:160)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12986)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:38)
08-17 17:59:07.334 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12986)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableOnErrorReturn.subscribeActual(FlowableOnErrorReturn.java:33)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12986)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12932)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableConcatArray$ConcatArraySubscriber.onComplete(FlowableConcatArray.java:139)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableConcatArray.subscribeActual(FlowableConcatArray.java:40)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12986)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.Flowable.subscribe(Flowable.java:12932)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.onNext(FlowableFlatMap.java:163)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnSubscriber.runAsync(FlowableObserveOn.java:400)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:176)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
08-17 17:59:07.335 12744-13103/com.nowait.menu.admin W/System.err:  ... 7 more

1 个答案:

答案 0 :(得分:0)

所以我发现在我的模型中我有一个getter,它将一个字符串url解析为一个URI对象,这就是它崩溃的原因