[BUG] ApiClient class introduced by the java resttemplate generator will not pass a SpotBugs validation
Created by: gmcelhoe
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? The problem is easily seen by inspection of the generated sample code or the mustache files -
Have you validated the input using an OpenAPI validator (example)? N/A -
What's the version of OpenAPI Generator used? 4.0.3 -
Have you search for related issues/PRs? Yes -
What's the actual output vs expected output? Described below -
[Optional] Bounty to sponsor the fix (example)
Description
The ApiClient class introduced by the java resttemplate generator will not pass a SpotBugs validation.
At https://github.com/OpenAPITools/openapi-generator/blob/3785165e079de8f36f3baf774897feb1065576ba/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache#L622 a check for returnType == null is performed, after the returnType variable was already dereferenced at https://github.com/OpenAPITools/openapi-generator/blob/3785165e079de8f36f3baf774897feb1065576ba/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache#L614
openapi-generator version
4.0.3
OpenAPI declaration file content or url
N/A
Command line used for generation
Steps to reproduce
Related issues/PRs
Related issue is https://github.com/OpenAPITools/openapi-generator/issues/33 , which could catch the problem during the build.
Suggest a fix
The fix is simply to remove the null check at line 622, as it cannot be reached due to the NPE would would happen on line 614.