mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 15:12:45 +00:00
fix handleResponse to not leak okhttp connections (#4997)
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user