Skip to content

Conversation

Fr4nk03
Copy link

@Fr4nk03 Fr4nk03 commented Oct 1, 2025

Description

Problem: The test io.swagger.v3.jaxrs2.util.ServletUtilsTest.convertWithRightOutputSize can fail intermittently because multivaluedMap.keySet() does not guarantee the order of the keys.This non-deterministic behavior was detected using the NonDex tool. This pull request is for a simple fix to make the test deterministic.

Reference: https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/MultivaluedHashMap.html

Fixes: This PR replaces the order-dependent assertion with a robust check that verifies the presence of the expected keys. By using assertTrue(multivaluedMap.containsKey("key1")) and assertTrue(multivaluedMap.containsKey("key2")), the test correctly validates the map's contents without relying on iteration order, making it deterministic and reliable.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

Log from NonDex:
[ERROR] Failures:
[ERROR] ServletUtilsTest.convertWithRightOutputSize:29 expected [key1] but found [key2]
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Update ServletUtilsTest.java

Previously, I checked "key1" twice. It should check both "key1" and "key2"
@Fr4nk03 Fr4nk03 force-pushed the bug/fix-nondeterminism-servletutils-test branch from 2653220 to 72c8412 Compare October 2, 2025 16:04
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