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
  • Merge requests
  • !1533

SpringCodeGen - Use InputStreamResource To Allow Streaming of File From Body

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/ashmeet-kandhari/InputStreamResource_Fix into master Nov 23, 2018
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

Created by: ashmeet-kandhari

Currently the SpringCodeGen uses the class org.springframework.core.io.Resource to handle a file type which results in the input stream being read into a byte[] in memory. This is a problem if an API is to handle large files or used in a high concurrency environment as it means you need a large heap/likely to get OutOfMemoryExceptions.

When debugging against spring-web 5.0.6.RELEASE we can see that in org.springframework.http.converter.ResourceHttpMessageConverter#readInternal if the class is org.springframework.core.io.Resource then a ByteArrayResource is produced containing the entire body as a byte[], however if the supplied class is org.springframework.core.io.InputStreamResource then we get an instance of InputStreamResource which just wraps the underlying stream.

So we have switched to use org.springframework.core.io.InputStreamResource instead of Resource and we can now handle the body as a stream. This leaves it to developer to decide the optimal approach for their given use case.

In the PR checklist it says to update the Petstore samples, however we saw that for windows there are a limited number of spring related batch files when compared to the shell scripts. We ran the batch files and we found that in addition to our change there were a number of other changes which look to be related to JDK version (we are using jdk 8), so we didn't commit them just in case this caused confusion.

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ashmeet-kandhari/InputStreamResource_Fix