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
  • #8492
Closed
Open
Issue created Jan 20, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [Client] [Java] [Vertx] Current context may return NPE when creating new WebClient

Created by: ricardozanini

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Hi!

While testing the generated client code for the petstore.yaml example, the ApiClient.java code is returning NPEs the first time it tries to create a WebClient reference. More specifically here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/vertx/ApiClient.mustache#L124-L132

Is there a reason to not use this.vertx.getOrCreateContext() instead? The vertx attribute is final. I can send a small PR to fix this, but I'd like to hear from the contributors first.

openapi-generator version

5.0.0

OpenAPI declaration file content or URL

Tested with petstore.yaml simple example.

Generation Details

Here's my plugin configuration:

<build>
    <plugins>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${version.openapi.generator}</version>
        <executions>
          <execution>
            <id>default</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/main/resources/petstore.yaml</inputSpec>
              <generatorName>java</generatorName>
              <library>vertx</library>
              <configOptions>
                <dateLibrary>java8</dateLibrary>
              </configOptions>
              <apiPackage>${project.groupId}.client</apiPackage>
              <modelPackage>${project.groupId}.client</modelPackage>
              <invokerPackage>${project.groupId}.client</invokerPackage>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <generateModelDocumentation>false</generateModelDocumentation>
              <generateApiDocumentation>false</generateApiDocumentation>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
Steps to reproduce
  1. Generate the Code
  2. Run the tests with Junit5 and Vertx 3.9.5 (https://vertx.io/docs/3.9.5/vertx-junit5/java/)
Related issues/PRs

There's none

Suggest a fix

Replace Vertx.currentContext with this.vertx.getOrCreateContext()

By the way, I see that the server-side was upgraded to Vertx 4 (#7352 (closed)). Don't we need to upgrade the client code as well? I can also send a PR for this purpose.

Assignee
Assign to
Time tracking