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

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

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 15
    • 15
    • core-libs
    • b26

      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.

            pconcannon Patrick Concannon (Inactive)
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: