Skip to content

Conversation

@Anshul-creator
Copy link
Contributor

@Anshul-creator Anshul-creator commented Nov 6, 2025

What is the purpose of the change?

This PR stabilizes URLParam.hashCode() to eliminate Non-Dex flakiness in tests (notably URLTest.hashCode).

Root Cause

The previous implementation multiplied hashCodeCache by 31 for each map entry.
Because iteration order over EXTRA_PARAMS (a HashMap) is nondeterministic, the resulting hash code varied between runs, breaking consistency with equals() and causing nondeterministic test failures.

Changes Made

  • Replaced the order-dependent multiplication-based accumulation with an order-independent summation of entry.hashCode() values.
  • Kept the same handling for VALUE, KEY, and ignored TIMESTAMP_KEY.
  • Preserved the existing structure and caching logic.

Verification

You can try running the following snippet of code from the dubbo repo root, on both pre-fix and post-fix code

./mvnw -pl dubbo-common edu.illinois:nondex-maven-plugin:2.2.1:nondex \
  -DnondexRuns=20 \
  -Dtest=org.apache.dubbo.common.URLTest#testHashcode

The test should fail intermittently on the pre-fix version, but pass consistently across all seeds on the post-fix version.
NonDex run logs will be available under the dubbo-common/.nondex directory.

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@Anshul-creator Anshul-creator changed the title Fix unstable test URLTest.testHashcode Fix: Stabilize URLParam.hashCode() to prevent Non-Dex nondeterminism in URLTest.testHashcode Nov 6, 2025
@Anshul-creator Anshul-creator marked this pull request as ready for review November 6, 2025 16:53
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.77%. Comparing base (3720471) to head (9d3bcc2).

Files with missing lines Patch % Lines
...rg/apache/dubbo/common/url/component/URLParam.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##                3.3   #15757   +/-   ##
=========================================
  Coverage     60.76%   60.77%           
- Complexity    11727    11728    +1     
=========================================
  Files          1938     1938           
  Lines         88637    88638    +1     
  Branches      13380    13379    -1     
=========================================
+ Hits          53864    53867    +3     
- Misses        29245    29246    +1     
+ Partials       5528     5525    -3     
Flag Coverage Δ
integration-tests-java21 32.38% <80.00%> (+0.05%) ⬆️
integration-tests-java8 32.40% <80.00%> (-0.14%) ⬇️
samples-tests-java21 32.05% <80.00%> (-0.07%) ⬇️
samples-tests-java8 29.82% <80.00%> (-0.01%) ⬇️
unit-tests-java11 59.03% <80.00%> (+<0.01%) ⬆️
unit-tests-java17 58.52% <80.00%> (+0.01%) ⬆️
unit-tests-java21 58.50% <80.00%> (+<0.01%) ⬆️
unit-tests-java25 58.48% <80.00%> (+0.01%) ⬆️
unit-tests-java8 59.02% <80.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@heliang666s
Copy link
Member

LTGM

Copy link
Contributor

@zrlw zrlw left a comment

Choose a reason for hiding this comment

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

LGTM

@zrlw zrlw merged commit 7cee17d into apache:3.3 Nov 10, 2025
33 checks passed
@Anshul-creator Anshul-creator deleted the fix-testHashcode branch November 10, 2025 15:59
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