Skip to content

test: fix assuming toString order with multiple ports in org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest#16153

Open
Archonic944 wants to merge 2 commits intoapache:3.3from
Archonic944:3.3
Open

test: fix assuming toString order with multiple ports in org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest#16153
Archonic944 wants to merge 2 commits intoapache:3.3from
Archonic944:3.3

Conversation

@Archonic944
Copy link
Copy Markdown

@Archonic944 Archonic944 commented Mar 21, 2026

What is the purpose of the change?

The purpose of this change is to modify the test org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest so that it consistently succeeds.
Fixes #16152 .

Why does the test fail?

The test's implementation compares status message output (from a ThreadPoolStatusChecker) against an expected string. The expected string contains an exact order, but the ThreadPoolStatusChecker in reality iterates over a Map.entrySet() to produce its static string. Therefore, iteration order is not guaranteed. When the map returns a different order than usual, which is valid under Java specifications, the test fails.

How to reproduce the test failure

Run the test with NonDex to shuffle collection iteration order:

  mvn edu.illinois:nondex-maven-plugin:2.2.1:nondex \
    -pl dubbo-rpc/dubbo-rpc-dubbo \
    -Dtest=org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest#test \
    -DnondexRuns=10

Expected results

The test expects

Pool status:WARN, max:1, core:1, largest:0, active:0, task:0, service port: 8888;
Pool status:OK, max:10, core:10, largest:0, active:0, task:0, service port: 8889

to be returned from ThreadPoolStatusChecker#check#getMessage.

Actual results

When the collection order is shuffled, the test receives

Pool status:OK, max:10, core:10, largest:0, active:0, task:0, service port: 8889;
Pool status:WARN, max:1, core:1, largest:0, active:0, task:0, service port: 8888

Description of Fix

Instead of comparing the status message to an exact string:

  1. Split the status message by ;. Ensure that there are only two items in the returned array.
  2. Ensure that the status message (as a whole) contains both expected pieces, regardless of order.

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?

@Archonic944 Archonic944 changed the title test: assuming toString order with multiple ports in org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest test: fix assuming toString order with multiple ports in org.apache.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusCheckerTest Mar 21, 2026
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.

[Bug] ThreadPoolStatusCheckerTest#test fails when collection order is shuffled with NonDex

1 participant