Skip to content

Conversation

anthonyx24
Copy link
Contributor

@anthonyx24 anthonyx24 commented Oct 2, 2025

Issue: This is the same issue as #4946 for a different class, since there is also a JSON string comparison here. In summary, since JSONs are unordered, after converting them to strings, the parameter ordering is not guaranteed. For another example of this issue being addressed, see this previous merged PR.

This test was flagged via the NonDex tool, which detects potentially unreliable tests due to underlying Java API assumptions. To see the Nondex output for this test, you can run:

mvn -pl metrics/metrics-core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest="org.apache.servicecomb.metrics.core.publish.TestThreadPoolPublishModelFactory#createDefaultPublishModel"

Fix: The fix here is also similar to the one I detailed in this PR for the other issue: #4947. I use JSONAssert's assertEquals() method, using non-strict checking (which ignores parameter ordering). This compares the JSON strings without enforcing parameter ordering, which removes the potentially unreliable nature of these tests. This library is already included within the spring-boot dependency, which is already used in the project, so there's no need to update the pom file. Rerunning Nondex shows a passing result.

PR Checklist:

  • Github Issue: [BUG] - Nondeterminism in unit test TestThreadPoolPublishModelFactory due to JSON parameter ordering #4968
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install -Pit to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.

@anthonyx24 anthonyx24 changed the title Change TestThreadPoolPublishModelFactory to deterministic implementation [#4968] Change TestThreadPoolPublishModelFactory to deterministic implementation Oct 2, 2025
@liubao68 liubao68 merged commit 86632c9 into apache:master Oct 11, 2025
4 of 5 checks passed
@anthonyx24 anthonyx24 deleted the fix-thread-pool-publish-model-factory-test branch October 20, 2025 03:30
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