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 ----------
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 ----------
- duplicates
-
JDK-8204233 Add configurable option for enhanced socket IOException messages
-
- Closed
-