Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3480
Closed
Open
Issue created Jul 27, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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.

Assignee
Assign to
Time tracking