Uploaded image for project: 'EJB Client Library (AS7+)'
  1. EJB Client Library (AS7+)
  2. EJBCLIENT-418

Fixed test flakniess due to indeterminate HashMap ordering

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.45.Final
    • None
    • None

      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.

              cfang@redhat.com Cheng Fang
              kaiyaok2 Kaiyao Ke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: