forked from loafle/openapi-generator-original
fix handleResponse to not leak okhttp connections (#4997)
This commit is contained in:
parent
8fb71b46db
commit
3c1a8daaf9
@ -1027,6 +1027,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
@ -1032,6 +1032,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
@ -1033,6 +1033,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
@ -1034,6 +1034,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user