使用请求主体调用api POST请求时的StringIndexOutOfBounds异常

时间:2018-02-26 19:59:12

标签: android retrofit2

我可以看到,在我的应用中进行某个api调用时,我的许多用户都开始遇到崩溃。 不过,这似乎是内部库崩溃。

我可以看到两个重复的堆栈跟踪:

Caused by java.lang.StringIndexOutOfBoundsException: String 
index out of range: 6422625
       at java.lang.String.codePointAt(String.java:602)
       at java.util.WeakHashMap.transfer(WeakHashMap.java:499)
       at java.util.WeakHashMap.resize(WeakHashMap.java:475)
       at java.util.WeakHashMap.put(WeakHashMap.java:448)
       at java.util.Collections$SynchronizedMap.put(Collections.java:2318)
       at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:573)
       at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:741)
       at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:95)
       at java.lang.reflect.Method.getParameterAnnotationsNative(Method.java)
       at java.lang.reflect.Method.getParameterAnnotations(Method.java:594)
       at retrofit2.ServiceMethod$Builder.(ServiceMethod.java:158)
       at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
       at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
       at java.lang.reflect.Proxy.invoke(Proxy.java:813)
       at $Proxy2.a(Unknown Source)
  ... 

Caused by java.lang.StringIndexOutOfBoundsException: String index out of range: 16
   at java.lang.String.codePointAt(String.java:602)
   at java.util.WeakHashMap.transfer(WeakHashMap.java:499)
   at java.util.WeakHashMap.resize(WeakHashMap.java:475)
   at java.util.WeakHashMap.put(WeakHashMap.java:448)
   at java.util.Collections$SynchronizedMap.put(Collections.java:2318)
   at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:573)
   at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:741)
   at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:95)
   at java.lang.reflect.Method.getParameterAnnotationsNative(Method.java)
   at java.lang.reflect.Method.getParameterAnnotations(Method.java:594)
   at retrofit2.ServiceMethod$Builder.(ServiceMethod.java:158)
   at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
   at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
   at java.lang.reflect.Proxy.invoke(Proxy.java:813)
   at $Proxy2.a(Unknown Source)

我们的大多数用户都是三星galaxy用户,受影响的用户大多使用Android 7。 知道这可能是由什么造成的吗?

改造方法是一个带有请求体的post方法,带有自定义标头,我们也使用拦截器。

另一个问题是崩溃解决方案中的相同崩溃类型如下:

Caused by java.lang.ArrayStoreException: android.os.Parcel cannot be stored in an array of type java.util.WeakHashMap$Entry[]
   at java.util.WeakHashMap.transfer(WeakHashMap.java:507)
   at java.util.WeakHashMap.resize(WeakHashMap.java:475)
   at java.util.WeakHashMap.put(WeakHashMap.java:448)
   at java.util.Collections$SynchronizedMap.put(Collections.java:2318)
   at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:573)
   at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:741)
   at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:95)
   at java.lang.reflect.Method.getParameterAnnotationsNative(Method.java)
   at java.lang.reflect.Method.getParameterAnnotations(Method.java:594)
   at retrofit2.ServiceMethod$Builder.(ServiceMethod.java:158)
   at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
   at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
   at java.lang.reflect.Proxy.invoke(Proxy.java:813)
   at $Proxy2.a(Unknown Source)

0 个答案:

没有答案