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

Port number in java.net.ConnectException would be useful

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 5.0
    • core-libs
    • Fix Understood
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      The reason/message in a java.net.ConnectException does not display the port that the connection attempt was made to (it display the hostname/ip only).

      JUSTIFICATION :
      When debugging multiple connections to the same host it would be useful to know the (remote) port number in order to (potentially) make debugging easier.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
       This shows what I'd like to see (using 1234 as an example port number).

      java.net.ConnectException: Connection refused to host: 127.0.0.1:1234; nested exception is:
              java.net.ConnectException: Connection refused: connect
              at some.class.someMethod ...
      ACTUAL -
      Here it is...

      java.net.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
              java.net.ConnectException: Connection refused: connect
              at some.class.someMethod ...


      ---------- BEGIN SOURCE ----------
      Trivial but requires 3rd party APIs (as no core JDK methods throw this explicitly - maybe only as a subclass of IOException). I encountered it using AdventNet (RMI) MBeanServerConnection - while deliberately failing a connection as part of testing failure modes. I encountered it numerous times before in other APIs.
      ---------- END SOURCE ----------

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: