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

Loopback SSLSocketImpl createSocket is throwing an exception.

XMLWordPrintable

    • b50
    • generic
    • generic
    • Verified

        i've been looking at a bug filed against J2ME CDC Security Optional
        Package and, while developing a test case, i ran onto behavior
        which seems to me to be a bug, but i wanted to check with you guys
        first.

        i'm attaching an example. in essence, i do this:

                    SocketFactory f = SocketFactory.getDefault();
                    Socket s = f.createSocket( (String)null, 8080 );

        and i create a loopback socket, as per the spec for java.net.Socket.
        the createSocket() call throws an exception, but it's an
        IOException which indicates "Connection refused" because i don't
        have anything listening on that socket. no problem there. however,
        then i do this:

                    SSLSocketFactory f =
                (SSLSocketFactory)SSLSocketFactory.getDefault();
                    SSLSocket s = (SSLSocket)f.createSocket( (String)null,
                                                             8080 );

        and i get an IllegalArgumentException from java.net.InetSocketAddress
        saying that an InetSocketAddress can't be created with a null
        hostname. since SSLSocket extends socket, and the spec doesn't
        mention any change in behavior, i would expect to get the same
        loopback behavior and another "Connection refused" exception.

        if i run another example which subclasses SSLSocket directly
        and passes a null hostname, i do seem to get a loopback socket
        and a "Connection refused" exception, so the problem only seems
        to arise with the default SSLSocketImpl that comes with J2SE.

        i've tried this first with the CDC SecOP CVM, and then with J2SE
        1.4.2 on solaris and linux, and a beta of J2SE 1.5.0. the behavior
        remains consistent. am i misunderstanding something here, or is
        this a bug? i took a quick look in bugtraq but didn't see anything
        right away which seemed related to this, so i wanted to check to
        see if this was a known problem, or indeed isn't a problem for some
        reason.

              xuelei Xuelei Fan
              wetmore Bradford Wetmore
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: