所以我有一个使用Okhttp的简单http请求.我使用Android上的RxJava进行此 *** 作.我将此RxJava调用添加到Compositedisposable中,然后在onStop上清除它.由于某种原因在下面触发了此异常.我对如何解决它不确定.
Caused by java.lang.IllegalStateException: Unbalanced enter/exit at okio.AsyncTimeout.enter(AsyncTimeout.java:73) at okio.AsyncTimeout.read(AsyncTimeout.java:235) at okio.RealBufferedSource.read(RealBufferedSource.java:47) at okhttp3.internal.http1.http1Codec$AbstractSource.read(http1Codec.java:363) at okhttp3.internal.http1.http1Codec$FixedLengthSource.read(http1Codec.java:407) at okio.RealBufferedSource.read(RealBufferedSource.java:47) at okhttp3.internal.cache.CacheInterceptor.read(CacheInterceptor.java:174) at okhttp3.internal.Util.skipAll(Util.java:175) at okhttp3.internal.Util.discard(Util.java:157) at okhttp3.internal.cache.CacheInterceptor.close(CacheInterceptor.java:202) at okio.RealBufferedSource.close(RealBufferedSource.java:469) at okio.RealBufferedSource.close(RealBufferedSource.java:453) at java.nio.channels.Channels$ReadableByteChannelimpl.implCloseChannel(Channels.java:255) at java.nio.channels.spi.AbstractInterruptibleChannel.interrupt(AbstractInterruptibleChannel.java:166) at java.lang.Thread.interrupt(Thread.java:957) at java.util.concurrent.FutureTask.cancel(FutureTask.java:146) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.cancel(ScheduledThreadPoolExecutor.java:258) at io.reactivex.internal.schedulers.ScheduledRunnable.dispose(ScheduledRunnable.java:107) at io.reactivex.disposables.Compositedisposable.dispose(Compositedisposable.java:217) at io.reactivex.disposables.Compositedisposable.dispose(Compositedisposable.java:80) at io.reactivex.internal.schedulers.IoScheduler$EventLoopWorker.dispose(IoScheduler.java:210) at io.reactivex.Scheduler$disposeTask.dispose(Scheduler.java:464) at io.reactivex.internal.disposables.disposableHelper.dispose(disposableHelper.java:125) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.dispose(ObservableSubscribeOn.java:74) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.dispose(ObservableObserveOn.java:146) at io.reactivex.internal.disposables.disposableHelper.dispose(disposableHelper.java:125) at io.reactivex.observers.disposableObserver.dispose(disposableObserver.java:91) at io.reactivex.disposables.Compositedisposable.dispose(Compositedisposable.java:217) at io.reactivex.disposables.Compositedisposable.clear(Compositedisposable.java:183) at MyActivity.onStop(MyActivity.java:320) at androID.app.Instrumentation.callActivityOnStop(Instrumentation.java:1297) at androID.app.Activity.performStop(Activity.java:7159) at androID.app.ActivityThread.performDestroyActivity(ActivityThread.java:4625) at androID.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4691) at androID.app.ActivityThread.-wrap7(ActivityThread.java) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1718) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:154) at androID.app.ActivityThread.main(ActivityThread.java:6732) at java.lang.reflect.Method.invoke(Method.java) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
代码基本上是这样的:
Observable<Stuff> observable = Observable.create(new ObservableOnSubscribe<Stuff>() { @OverrIDe public voID subscribe(@NonNull ObservableEmitter<Stuff> e) throws Exception { //do Okhttp stuff, call onNext(stuff). } }) .subscribeOn(Schedulers.io()) .observeOn(AndroIDSchedulers.mainThread()); disposableObserver<Stuff> disposableObserver = observable .subscribeWith(new disposableObserver<Stuff>() {......}); disposables.add(disposableObserver);
解决方法:
一些AndroID VM中存在一个错误,无法与新的D8编译器交互.
https://github.com/square/okhttp/issues/3641#issuecomment-370717021
Google最近改进了D8,以避免触发该错误.
总结以上是内存溢出为你收集整理的android-CompositeDisposable.clear导致OkHttp抛出java.lang.IllegalStateException:不平衡的输入/退出全部内容,希望文章能够帮你解决android-CompositeDisposable.clear导致OkHttp抛出java.lang.IllegalStateException:不平衡的输入/退出所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)