Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8243507

DatagramSocket constructors don’t always specify what happens when passed invalid parameters

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b26

      Description

      There are two DatagramSocket constructors that accept a port number, one of which asserts "The local port must be between 0 and 65535 inclusive".

      However, neither constructor specify that an IAE is thrown if the port is out of range. The IAE comes from the instantiation of InetSocketAddress, which specifies "IllegalArgumentException – if the port parameter is outside the specified range of valid port values."

      Also, neither constructor specifies that if zero is passed for the port number, the system will choose any appropriate port. The two constructors rely on the assertion "A port number of zero will let the system pick up an ephemeral port in a bind operation" from the InetSocketAddress constructor.

      Would be good to specify that an IAE is triggered with an incorrect port for these DatagramSocket constructors, and that if zero is passed as port number to the constructors the system will pick any appropriate port number.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pconcannon Patrick Concannon
              Reporter:
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: