|
Response response = null; |
|
|
|
if ("GET".equals(method)) { |
|
response = invocationBuilder.get(); |
|
} else if ("POST".equals(method)) { |
|
response = invocationBuilder.post(entity); |
|
} else if ("PUT".equals(method)) { |
|
response = invocationBuilder.put(entity); |
|
} else if ("DELETE".equals(method)) { |
|
response = invocationBuilder.method("DELETE", entity); |
|
} else if ("PATCH".equals(method)) { |
|
response = invocationBuilder.method("PATCH", entity); |
|
} else if ("HEAD".equals(method)) { |
|
response = invocationBuilder.head(); |
|
} else if ("OPTIONS".equals(method)) { |
|
response = invocationBuilder.options(); |
|
} else if ("TRACE".equals(method)) { |
|
response = invocationBuilder.trace(); |
|
} else { |
|
throw new ApiException(500, "unknown method type " + method); |
|
} |
|
|
|
statusCode = response.getStatusInfo().getStatusCode(); |
|
responseHeaders = buildResponseHeaders(response); |
|
|
|
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { |
|
return null; |
|
} else if (response.getStatusInfo().getFamily().equals(Status.Family.SUCCESSFUL)) { |
|
if (returnType == null) |
|
return null; |
|
else |
|
return deserialize(response, returnType); |
|
} else { |
|
String message = "error"; |
|
String respBody = null; |
|
if (response.hasEntity()) { |
|
try { |
|
respBody = String.valueOf(response.readEntity(String.class)); |
|
message = respBody; |
|
} catch (RuntimeException e) { |
|
// e.printStackTrace(); |
|
} |
|
} |
|
throw new ApiException( |
|
response.getStatus(), |
|
message, |
|
buildResponseHeaders(response), |
|
respBody); |
|
} |
Bug Report Checklist
Description
Resteasy client template does not close the
Response(implementsAutoCloseable).openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/ApiClient.mustache
Lines 675 to 723 in 2252040
openapi-generator version
6.0.1
OpenAPI declaration file content or url
N/A
Generation Details
N/A
Steps to reproduce
N/A
Related issues/PRs
N/A
Suggest a fix
Handle the
Responseusing try-with-resources, such as: https://github.com/MikeEdgar/openapi-generator/blob/06e93fabbfd66cd4f0f26d47bfba32a9ce3992d4/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/ApiClient.mustache#L675-L730