okhttp3 ResponseBody to String Issue

2.5k Views Asked by At

i'm working a spark app (language > scala) ,

and using okhttp3 3.6.0 ver.

An error occurs when calling the below method.

val client = new OkHttpClient()
....
val response = client.newCall(request).execute()
response.body().string()

Exception :

Exception in thread "main" java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z
    at okhttp3.internal.Util.bomAwareCharset(Util.java:412)
    at okhttp3.ResponseBody.string(ResponseBody.java:173)

please help me :'(

ps.

scala version : 2.10.6 
spark version : 1.6.3
okhttp version : 3.6.0
1

There are 1 best solutions below

0
On

You’re using an obsolete version of Okio. Configure it to be 1.13.0 and you’ll be good.