Skip to content

Conversation

@Anshul-creator
Copy link
Contributor

What is the purpose of the change?

This PR stabilizes several tests inside ReferenceCacheTest that were intermittently failing under randomized execution orders (NonDex):

  • testGetCacheSameReference
  • testGetCacheDiffReference
  • testGetCacheWithKey
  • testGetCacheDiffName
  • testDestroy
  • testDestroyAll

All of these tests invoke reference creation through ReferenceConfig.get(), which cause the metrics subsystem to be initialized. This introduces nondeterministic behavior that causes intermittent test failures unrelated to the core reference-caching logic.

Root Cause

These failures are identical to previously fixed issues in:

Each of those PRs addressed flakiness caused by Micrometer’s CompositeMeterRegistry, which can throw an ArrayIndexOutOfBoundsException when it iterates over internal IdentityHashMap structures under randomized execution orders (NonDex).

ReferenceCacheTest suffered from the same underlying issue:
Dubbo framework state was leaking between test methods. This meant that the behavior of reference creation in one test could affect subsequent tests, causing nondeterministic failures.

Changes Made

To fully isolate each test method and eliminate shared state, the following changes were applied:

  • All Dubbo-related system properties were cleared at the beginning of each test so that no stale configuration could influence behavior.
  • Metrics were explicitly disabled for the entire test class by setting the appropriate system properties.
  • After each test, Dubbo was reset again, system properties were cleared, and the reference cache was emptied to guarantee that no state persisted into the next test.

Together, these changes ensure that every test in ReferenceCacheTest starts from a completely clean, predictable environment, eliminating flaky behavior caused by shared or leaked state.

Verification

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

./mvnw -q -pl dubbo-config/dubbo-config-api \
  edu.illinois:nondex-maven-plugin:2.2.1:nondex \
  -DnondexRuns=20

The tests 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-config/dubbo-config-api/.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?

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.76%. Comparing base (9b32dc1) to head (dc17352).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15794      +/-   ##
============================================
- Coverage     60.76%   60.76%   -0.01%     
+ Complexity    11698    11694       -4     
============================================
  Files          1938     1938              
  Lines         88646    88646              
  Branches      13379    13379              
============================================
- Hits          53868    53866       -2     
- Misses        29250    29252       +2     
  Partials       5528     5528              
Flag Coverage Δ
integration-tests-java21 32.36% <ø> (ø)
integration-tests-java8 32.54% <ø> (+0.09%) ⬆️
samples-tests-java21 31.98% <ø> (-0.08%) ⬇️
samples-tests-java8 29.62% <ø> (-0.08%) ⬇️
unit-tests-java11 59.07% <ø> (-0.01%) ⬇️
unit-tests-java17 58.53% <ø> (-0.02%) ⬇️
unit-tests-java21 58.55% <ø> (-0.02%) ⬇️
unit-tests-java25 58.49% <ø> (-0.04%) ⬇️
unit-tests-java8 59.04% <ø> (-0.03%) ⬇️

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.

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
Copy link
Contributor

zrlw commented Nov 24, 2025

maybe you could combine similar revisions into a single PR to reduce unnecessary repetitive work.

@Anshul-creator
Copy link
Contributor Author

I will definitely keep that in mind for future. Just to be safe and make PR's more easily acceptable I added changes one test file per PR

@RainYuY
Copy link
Contributor

RainYuY commented Nov 24, 2025

These PRs are very good. Thanks for your great work. I want to suggest: how about using one issue to describe these changes and some sub-issues to refer to these PRs? I think it would be more structured and let others know what is happening and why. @Anshul-creator

@RainYuY
Copy link
Contributor

RainYuY commented Nov 24, 2025

And we will know when these fixes are done. ^^

@Anshul-creator
Copy link
Contributor Author

@RainYuY I’ve created the tracking issue as you suggested and included all the relevant context and links to the associated PRs:

#15795

Please let me know if this looks good, thanks!

@RainYuY
Copy link
Contributor

RainYuY commented Nov 25, 2025

@RainYuY I’ve created the tracking issue as you suggested and included all the relevant context and links to the associated PRs:

#15795

Please let me know if this looks good, thanks!

Very good. Thanks. I or others will review these PRs later.

Copy link
Contributor

@RainYuY RainYuY left a comment

Choose a reason for hiding this comment

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

LGTM

@RainYuY RainYuY merged commit 91cdd78 into apache:3.3 Nov 26, 2025
33 checks passed
@Anshul-creator Anshul-creator deleted the fix-ReferenceCacheTest branch November 27, 2025 06:11
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