HttpURLConnection uc = (HttpURLConnection)urlImge.openConnection();
uc.setConnectTimeout(5000);
uc.setReadTimeout(5000);
uc.setDoInput(true);
uc.setRequestProperty("Authorization", "Basic " + encoding);
if ((uc.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED){
...
}
uc.getResponseCode() in the above code occasionally throws the following exception:
Exception: size=32 offset=0 byteCount=1448
Class: java.lang.ArrayIndexOutOfBoundsException
Stack trace: java.lang.ArrayIndexOutOfBoundsException: size=32 offset=0 byteCount=1448
at com.android.okhttp.okio.Util.checkOffsetAndCount(Util.java:31)
at com.android.okhttp.okio.Okio$1.write(Okio.java:73)
at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:157)
at com.android.okhttp.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:177)
at com.android.okhttp.okio.RealBufferedSink.writeUtf8(RealBufferedSink.java:59)
at com.android.okhttp.internal.http.Http1xStream.writeRequest(Http1xStream.java:169)
at com.android.okhttp.internal.http.Http1xStream.writeRequestHeaders(Http1xStream.java:125)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:606)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
Could anyone shed some light on the possible causes?