FISH-7965 OpenAPI endpoint crashes on duplicate types #6563
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
mvn clean package
GET /openapi
. Observe error.mvn clean package
GET /openapi
. Observe correct OpenAPI spec.Testing Environment