Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-17314

Reduce port collisions in JUnits

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Several Junit tests passes a non-zero port number to ServerSocketUtil.getPort().
      I noticed that those non-zero values are shared between test methods. Based, on the implementation of ServerSocketUtil.getPort(), the port is checked then, the socket is closed immediately.
      Two concurrent tests can have the same port number, but one of them fails with binding exceptions.

      Passing a zero port number reduces the probability of returning the same port numbers in two different tests, because the ServerSocketUtil.getPort() will call a random port number.

      An example of that is as described in HDFS-15618. testRead() between TestBlockTokenWithDFSStriped and TestBlockTokenWithDFS where port 19870 is used by the two test cases.

        Attachments

        1. HADOOP-17314.001.patch
          17 kB
          Ahmed Hussein

          Activity

            People

            • Assignee:
              ahussein Ahmed Hussein
              Reporter:
              ahussein Ahmed Hussein
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: