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

SocketException should provide the ip address and port that caused the problem.

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Duplicate
    • P4
    • None
    • 6u26
    • core-libs
    • x86
    • windows_xp

    Description

      A DESCRIPTION OF THE REQUEST :
      Most enterprise applications connect to multiple servers to operate. If one of those servers go down, then we see a ConnectException or SocketException stack trace in the log file. And it is very difficult to find out the connection to which server caused the issue by looking at the stack trace.

      So it would be really helpful lot if the stack trace of all the exceptions in java.net package provide the host and port information that caused the exception.

      JUSTIFICATION :
      It would take only very minimal change to include the ip address and port in the exception details. And it would save a lot of trouble for developers and maintenance staff of various applications to identify the issue.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
       java.net.ConnectException: Connection timed out: connect (java.sun.com:2555)
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at java.net.Socket.<init>(Socket.java:375)
      at java.net.Socket.<init>(Socket.java:189)
      at SocketErrorSimulator.main(SocketErrorSimulator.java:14)
      ACTUAL -
       java.net.ConnectException: Connection timed out: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at java.net.Socket.<init>(Socket.java:375)
      at java.net.Socket.<init>(Socket.java:189)
      at SocketErrorSimulator.main(SocketErrorSimulator.java:14)

      ---------- BEGIN SOURCE ----------
      import java.net.Socket;
      public class SocketErrorSimulator {

      public static void main(String[] args) throws Exception {
      Socket soc = new Socket("java.sun.com",2555);

      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The application can catch the exception and log the details of the server that it was trying to connect to, along with the stack trace.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              coffeys Sean Coffey
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: