我最近开始在registfit/okhttp上遇到问题。每当应用程序执行一个请求时,它就会崩溃,并出现错误:
05-18 12:13:51.908 E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: <<APP PACKAGE NAME>>, PID: 10264
java.lang.reflect.UndeclaredThrowableException
at $Proxy0.intercept(Unknown Source)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.trackResponseBody(OkHttpInterceptorHandler.java:58)
at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.invoke(OkHttpInterceptorHandler.java:39)
at java.lang.reflect.Proxy.invoke(Proxy.java:813)
at $Proxy0.intercept(Unknown Source)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.IllegalArgumentException: byteCount < 0: -1
at okio.RealBufferedSource.request(RealBufferedSource.java:64)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.trackResponseBody(OkHttpInterceptorHandler.java:58)
at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.invoke(OkHttpInterceptorHandler.java:39)
at java.lang.reflect.Proxy.invoke(Proxy.java:813)
at $Proxy0.intercept(Unknown Source)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
下面的类名在堆栈跟踪中。我猜这是Android Studio新的OkHttp探查器中的一个bug。你应该向他们报告一个bug;他们会很快修好的。
com.android.tools.profiler.support.network.OKHttpInterceptorHandler。
问题内容: 我正在使用OkHttp客户端和Jackson的Retrofit进行Json序列化,并想获取响应的标头。 我知道我可以扩展OkClient并拦截它。但这是在反序列化过程开始之前进行的。 我基本上需要的是将标头与反序列化的Json Object一起使用。 问题答案: 在Retrofit 1.9.0中,如果您使用接口的回调异步版本, 然后您的回调将收到一个对象 其中有一个方法叫做 对于Ret
主要活动 公共类MainActivity扩展AppCompatActivity{String response; 公共类GetExample{OkHttpClient客户端; Xml文件
我正在安装Jolokia的tomcat上运行这个。 我得到的是这个 {"error_type":"javax.management.运行时操作异常","错误":"javax.management.运行时操作异常:异常调用方法readBufsize","状态": 500,"stackTrace":"javax.management.运行时操作异常:异常调用方法readBufsize\n\tatorg
我对react原生版APK有一个问题。 这是我的包裹:
我有一个简单的用例,服务器为请求返回Etag,并将该Etag作为标头(即)添加到所有后续url请求。如果响应中有变化,服务器可以用响应,否则可以用响应。对于后者,重用缓存中的响应是有意义的。但是okhttp总是返回作为缓存响应。 我做了一些故障排除,okhttp在内部将响应写入磁盘,但是不会将其返回到。仔细研究类,有一些文档明确说明不会使用缓存: 编辑-更正,Okhttp正确地添加了etag标头。
我有一个带有POST REST API的SpringBoot2.2 webservice。我正在使用Okhttp客户机向第三方服务发出请求。我希望将第三方服务的确切响应返回给我的WebService的调用者。所有okhttp食谱都参考: 我尝试在api中返回okhttp响应,但我只返回调用方示例: 有人知道如何将Okhttp响应对象转换为Spring ResponseEntity对象以便返回htt