-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Describe the bug
maven :error when connect by okhttp.
Error information
Handler dispatch failed; nested exception is java.lang.NoSuchMethodError:okhttp3.RequestBody.create(Ljava/lang/String;Lokhttp3/MediaType;)Lokhttp3/RequestBody;
Class: org.openapitools.db_data.client.ApiClient.java
method: public RequestBody serialize(Object obj, String MediaType)
Info: RequestBody.create(MediaType,XXXX) in okhttps 3.x
Steps to reproduce the issue locally
Maven Version: 5.0.0
OKhttp Dependencies verision:3.14.9
Environment
- OS Version: window
- Java SDK version: 8
Additional context
What's the okhttp3 version you're using ? Is this due to a difference in the way the source code is built(gradle /Kotlin/maven)? Or is it a problem with my local dependencies?I haven't found any other version that uses this : RequestBody.create(Ljava/lang/String;Lokhttp3/MediaType;)
if (obj instanceof byte[]) {
return RequestBody.create((byte[])((byte[])obj), MediaType.parse(contentType));
} else if (obj instanceof File) {
return RequestBody.create((File)obj, MediaType.parse(contentType));
} else if (!"application/x-ndjson".equals(contentType)) {
if ("text/plain".equals(contentType) && obj instanceof String) {
return RequestBody.create((String)obj, MediaType.parse(contentType));
} else if (this.isJsonMime(contentType)) {
String content;
if (obj != null) {
content = JSON.serialize(obj);
} else {
content = null;
}
return RequestBody.create(content, MediaType.parse(contentType));
} else if (obj instanceof String) {
return RequestBody.create((String)obj, MediaType.parse(contentType));
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
} else if (!(obj instanceof Iterable)) {
throw new ApiException("NDJSON content requires a collection of objects.");
} else {
StringBuilder ndjsonContent = new StringBuilder();
Iterator var4 = ((Iterable)obj).iterator();
while(var4.hasNext()) {
Object item = var4.next();
String json = JSON.serialize(item);
ndjsonContent.append(json).append("\n");
}
return RequestBody.create(ndjsonContent.toString(), MediaType.parse(contentType));
}
}