Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EJBCLIENT-418 fixed test flakniess due to indeterminate HashMap ordering #534

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

kaiyaok2
Copy link
Contributor

@kaiyaok2 kaiyaok2 commented Mar 22, 2022

https://issues.redhat.com/browse/EJBCLIENT-418

Description
The test testInvocationOnMixedModeCluster() in MixedModeServiceURLTestCase.java can fail nondeterministically. The issue is found using Nondex when running commands
mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=MixedModeServiceURLTestCase under javax directory after building all dependencies. The problem is in the function validateResults() that deals with ServiceURL. In NodeInformation.java, the code calls ServiceURL.Builder.create() (e.g. line 216), which uses the default iterator of a HashMap.entrySet(). An EntrySet of a normal HashMap does not guarantee any order. Therefore, serviceURL may have internal order permutation. When toString() is called, a sample output String can be "service:ejb.jboss:remote://localhost:7099;node=node2;cluster=mixed-ejb;ejb-module=my-foo-app/my-bar-module" in one run, and then "service:ejb.jboss:remote://localhost:7099;cluster=mixed-ejb;node=node2;ejb-module=my-foo-app/my-bar-module" in another run. These possibilities can make the unit test fail occasionally.

Reasons for Fixing
The test may fail been run in a different enviornment or when Java upgrades in the future.

Fixes
Split the String formatted ServiceURL by semicolon. Then convert the output String Array into a HashSet to allow order permutation. Then do a direct comparison between the nested HashSets.

@chengfang
Copy link
Contributor

@kaiyaok2 thanks for the fix. Can you create a JIRA issue to describe the problem, and link this PR to the issue?

@chengfang
Copy link
Contributor

@kaiyaok2 We require that all contributions be made under the terms of the Apache 2.0 License, http://www.apache.org/licenses/LICENSE-2.0 . Do you agree to these terms?

@kaiyaok2
Copy link
Contributor Author

@kaiyaok2 thanks for the fix. Can you create a JIRA issue to describe the problem, and link this PR to the issue?

For sure! I just created a JIRA issue: EJBCLIENT-418

@kaiyaok2
Copy link
Contributor Author

@kaiyaok2 We require that all contributions be made under the terms of the Apache 2.0 License, http://www.apache.org/licenses/LICENSE-2.0 . Do you agree to these terms?

I agree to these terms!

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