2017-05-18 1 views
1

J'ai récemment commencé à avoir un problème avec Retrofit/OkHttp. Chaque fois que l'application effectue une demande, il se bloque avec l'erreur:Retrofit/OkHttp plante en réponse

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)  

J'ai aucune idée pourquoi il fait ça. Le serveur renvoie 200, le corps retourné contient un JSON valide. La partie la plus bizarre est que rien n'a changé dans le code pour dire que je pourrais avoir introduit un bug ou quelque chose comme ça. Cela fonctionnait bien et tout à coup toutes les demandes que l'application fait s'écraser.

Est-ce que quelqu'un a une idée de ce qui pourrait se passer?

Il vaut probablement la peine de mentionner qu'avant d'envoyer la requête au serveur, je crypte le corps à l'intérieur d'un intercepteur. Mais je ne pense pas que ce soit un problème car le serveur renvoie la bonne réponse.

Merci :)

+0

Peut être cela peut vous aider https://github.com/square/retrofit/issues/1475#issuecomment-172241798 –

Répondre

3

Le nom de classe ci-dessous figurait dans votre trace de pile. Je suppose que c'est un bug dans le nouveau profileur OkHttp du studio Android. Vous devriez signaler un bug à eux; ils vont le réparer rapidement.

com.android.tools.profiler.support.network.OkHttpInterceptorHandler.

+1

J'ai désactivé le profilage avancé sous la rubrique « Modifier les configurations » et a obtenu autour de cela. Merci pour l'indice! – dazza5000