swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.04k stars 6.03k forks source link

Out of memory when running the swagger-codegen-maven-plugin #10878

Open Calin-Cosma opened 3 years ago

Calin-Cosma commented 3 years ago
Description

mvn clean install fails with OutOfMemory with the following stack trace

[DEBUG] Ref property, simple name: WSContentInformation
[DEBUG] Resolving example for property io.swagger.models.properties.IntegerProperty@d7e9e510...
[DEBUG] Resolving example for property io.swagger.models.properties.DateTimeProperty@8e13ddb...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  35.036 s
[INFO] Finished at: 2021-01-28T02:27:46+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Java heap space -> [Help 1]
java.lang.OutOfMemoryError: Java heap space
    at com.fasterxml.jackson.core.util.TextBuffer.carr (TextBuffer.java:778)
    at com.fasterxml.jackson.core.util.TextBuffer.expand (TextBuffer.java:739)
    at com.fasterxml.jackson.core.util.TextBuffer.append (TextBuffer.java:502)
    at com.fasterxml.jackson.core.io.SegmentedStringWriter.write (SegmentedStringWriter.java:58)
    at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._flushBuffer (WriterBasedJsonGenerator.java:1880)
    at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeRaw (WriterBasedJsonGenerator.java:497)
    at com.fasterxml.jackson.core.util.DefaultIndenter.writeIndentation (DefaultIndenter.java:91)
    at com.fasterxml.jackson.core.util.DefaultPrettyPrinter.writeObjectEntrySeparator (DefaultPrettyPrinter.java:302)
    at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writePPFieldName (WriterBasedJsonGenerator.java:304)
    at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writeFieldName (WriterBasedJsonGenerator.java:145)
    at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeFieldName (WriterBasedJsonGenerator.java:128)
    at com.fasterxml.jackson.databind.ser.std.StdKeySerializers$StringKeySerializer.serialize (StdKeySerializers.java:230)
    at com.fasterxml.jackson.databind.ser.std.StdKeySerializers$Dynamic.serialize (StdKeySerializers.java:199)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:610)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:536)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:30)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents (ObjectArraySerializer.java:256)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize (ObjectArraySerializer.java:216)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize (ObjectArraySerializer.java:26)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:633)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:536)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:30)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:633)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:536)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:30)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents (ObjectArraySerializer.java:256)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize (ObjectArraySerializer.java:216)
    at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize (ObjectArraySerializer.java:26)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:633)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:536)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:30)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:633)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError
Swagger-codegen version

Version 2.3.1 of the plugin.

The issue is not present for version 2.2.3 of the plugin.

Swagger declaration file content or url

https://www.friscris.be/ws/api/516/swagger.json

Command line used for generation

mvn clean install

plugin config in pom.xml:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>${swagger-codegen-maven-plugin-version}</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec> https://www.friscris.be/ws/api/516/swagger.json</inputSpec>
                <language>java</language>
                <!--<library>okhttp-gson</library>-->
                <library>resttemplate</library>
                <generateApis>true</generateApis>
                <generateApiDocumentation>false</generateApiDocumentation>
                <generateApiTests>false</generateApiTests>
                <generateModels>true</generateModels>
                <generateModelDocumentation>false</generateModelDocumentation>
                <generateModelTests>false</generateModelTests>
                <withXml>false</withXml>
                <configOptions>
                    <dateLibrary>java8</dateLibrary>
                    <sourceFolder>swagger</sourceFolder>
                </configOptions>
                <output>target/generated-sources/swagger</output>
            </configuration>
        </execution>
    </executions>
</plugin>
jcvanderwal commented 2 years ago

I have the same issue when processing a large spec (4500 lines in yml format). Does anybody have an idea on how to tackle that?