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

Ensure default media type order is preserved using LinkedHashSet in mergeArrays. Fixes #2671 #2672

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

limehee
Copy link
Contributor

@limehee limehee commented Aug 8, 2024

#2671 - Ensure default media type order is preserved using LinkedHashSet in mergeArrays

Description

This PR addresses issue #2671 by ensuring that the order of media types is preserved in the mergeArrays method of the MethodAttributes class. Previously, HashSet was used, which did not guarantee the order of media types, causing the default media type not to be prioritized. This has been fixed by using LinkedHashSet to maintain the insertion order.

Changes

  • MethodAttributes.java:

    • Modified mergeArrays method to use LinkedHashSet instead of HashSet to preserve the order of media types.
  • MethodAttributesTest.java:

    • Added unit tests to verify that the mergeArrays method preserves the order of media types and that the default media type is prioritized.
    • Tests include scenarios with both non-null and null arrays.

Testing

Added the following tests to MethodAttributesTest to ensure the functionality:

  • testMergeArrays: Verifies that the order of media types is preserved when merging two arrays.
  • testMergeArraysWithNullArray1: Verifies that the method handles null as the first array correctly.
  • testDefaultProducesMediaType: Verifies that the default produces media type is correctly set.
  • testDefaultConsumesMediaType: Verifies that the default consumes media type is correctly set.

Please review the changes and let me know if any further adjustments are needed.

Thank you!

@limehee limehee changed the title fix: Ensure default media type order is preserved using LinkedHashSet in mergeArrays (#2671) Ensure default media type order is preserved using LinkedHashSet in mergeArrays. Fixes #2671 Aug 8, 2024
@bnasslahsen bnasslahsen merged commit ae5ab58 into springdoc:main Sep 17, 2024
1 check failed
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.

2 participants