Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-7965 OpenAPI endpoint crashes on duplicate types #6563

Closed
wants to merge 1 commit into from
Closed

FISH-7965 OpenAPI endpoint crashes on duplicate types #6563

wants to merge 1 commit into from

Conversation

ghunteranderson
Copy link
Contributor

Description

This PR addresses GitHub issue #6369 (FISH-7965).

When the MicroProfile OpenAPI implementation is scanning for types, the same type may be discovered multiple times; I assume its class file is found in multiple jars. Payara attempts to store this list of types in a map indexed by type name. However, since the same type name appears more than once in the list, an exception is thrown and no OpenAPI spec is built.

I believe the bug was introduced in #6256 (FISH-6980) when the MicroProfile OpenAPI scanner was modified to scan libraries in the web archive.

I've implemented the solution suggested by issue author marcinpaton. That is, when duplicate types are found, one is discarded. It is not specified which type will be selected; only that exactly one will be used. I don't know if its possible to determine which type should be used. However, with the current behavior (HTTP 500), this feels like a step in the right direction.

Testing

New tests

No new automated tests were added.

Author of issue #6369 provided a reproducer.

Testing Performed

  1. Build master branch of Payara with command mvn clean package
  2. Deploy application using Payara Micro.
  3. Request GET /openapi. Observe error.
  4. Build branch with bug fix with command mvn clean package
  5. Deploy same application using Payara Micro.
  6. Request GET /openapi. Observe correct OpenAPI spec.

Testing Environment

  • Zulu JDK 11.0.21
  • Maven 3.9.5
  • Ubuntu 20.04.6 virtualized with WSL2

@pdurbin
Copy link

pdurbin commented Feb 14, 2024

@ghunteranderson it's exciting that you've come up with a fix! Do you happen to have a build of Payara that we can test? (I've never built it myself.) Thanks!

@aubi
Copy link
Contributor

aubi commented Feb 14, 2024

It looks good! I restarted the failed build (temporal issue).

@aubi
Copy link
Contributor

aubi commented Feb 23, 2024

Hi @pdurbin,
if you want to try it yourself, compiling Payara Community is quite simple:

https://docs.payara.fish/community/docs/General%20Info/Build%20Instructions.html

Short answer:

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 mvn clean install -T 16 -PQuickBuild -DskipTests

@pdurbin
Copy link

pdurbin commented Feb 23, 2024

@aubi thanks it seems to have built fine. I left some notes but I haven't had a chance to test /openapi yet.

@luiseufrasio luiseufrasio self-requested a review April 2, 2024 13:22
Copy link
Contributor

@luiseufrasio luiseufrasio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants