swagger-api / swagger-api/swagger-codegen-generators

[Java][Jersey2] Generated Jersey 2 ApiClient should be thread-safe

Open
#817 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

The generated Jersey 2 ApiClient for codegen v3 currently stores the most recent status code and response headers as fields, which are made available to the caller via accessor methods. This means that the client is not thread-safe if the caller needs to access the status code and/or response headers because it is possible for another caller to complete an invoke call prior to the status code and/or response headers being queried.

It appears that this is solved for other generators by returning status code and response headers via an HTTP info object, and in fact, it appears that this was done for Jersey 2 in codegen v2 - see swagger-api/swagger-codegen#7605 for details.

I'd like to propose that these changes be brought into codegen v3.

FWIW, I'm able to repro this issue using v3.0.23 by setting the following fields in my config.json using the java generator:

{
  // other options such as groupId, artifactId, etc
  // ...
  "dateLibrary": "java8",
  "library": "jersey2"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Java generator using config.json's dateLibrary java8 and library jersey2, then compare its generated client behavior with the referenced swagger-codegen#7605 change. Done means status codes and response headers can be accessed safely when concurrent callers use the generated Jersey 2 ApiClient.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.