swagger-api / swagger-api/swagger-codegen
Java Out Of Memory when generating a customized template
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I'm trying to generate a custom template using swagger-codegen-cli but i'm facing an out of memory problem.
I've already tried to increase Java Heap memory and I'd see the issue #6394 but it doesn't works for me either. (my JSON Spec doesn't have maxItems and minItems defined, but I tried setting maxItems to 2 and 10).
Command line used for generation
java -cp swagger-codegen-cli-2.4.13.jar:target/rsi-restassured-generator-1.0.0.jar io.swagger.codegen.Codegen -l RSI-RestAssured -i swagger.json -c config.json -o generated-code
Operational system and Java:
Ubuntu 20.04
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
Steps to reproduce
executing the "Command line used for generation" topic.
StackTrace
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.fasterxml.jackson.core.util.TextBuffer.carr(TextBuffer.java:886)
at com.fasterxml.jackson.core.util.TextBuffer.expand(TextBuffer.java:847)
at com.fasterxml.jackson.core.util.TextBuffer.append(TextBuffer.java:612)
at com.fasterxml.jackson.core.io.SegmentedStringWriter.write(SegmentedStringWriter.java:58)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._flushBuffer(WriterBasedJsonGenerator.java:1994)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeRaw(WriterBasedJsonGenerator.java:597)
at com.fasterxml.jackson.core.util.DefaultIndenter.writeIndentation(DefaultIndenter.java:91)
at com.fasterxml.jackson.core.util.DefaultPrettyPrinter.writeEndObject(DefaultPrettyPrinter.java:333)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeEndObject(WriterBasedJsonGenerator.java:331)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:646)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:252)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:213)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:22)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:252)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:213)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:22)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:252)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:213)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:22)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
Related issues/PRs
#6394
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the command shown with swagger-codegen-cli-2.4.13.jar, the custom RSI-RestAssured generator, swagger.json, and config.json. Read the Jackson serialization frames in the stack trace and compare the behavior with related issue #6394. Done means identifying the generation path that causes unbounded memory use and validating a fix against this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100