harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catherine Hope (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6531) [classlib][luni] URLConnection.getInputStream() does not throw IOException when the socket is closed
Date Fri, 28 May 2010 15:31:37 GMT
[classlib][luni] URLConnection.getInputStream() does not throw IOException when the socket
is closed

                 Key: HARMONY-6531
                 URL: https://issues.apache.org/jira/browse/HARMONY-6531
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Catherine Hope
            Priority: Minor

Calling URLConnection.getInputStream when the socket has been closed returns an input stream
that gives -1 when read from.  The RI throws an IOException in this situation:

DisconnectHttpServer server = new DisconnectHttpServer();
URLConnection conn = (new URL("http://localhost:" + server.server.getLocalPort())).openConnection();
conn.connect() // this will be successful, but the sockets will be closed immediately after
the connection

class DisconnectHttpServer extends Thread {
        ServerSocket server = new ServerSocket();
        DisconnectHttpServer() throws IOException {
            server.bind(new InetSocketAddress(InetAddress.getByName("localhost"), 0));
        public void run() {
            try {
                Socket s = server.accept();
            } catch (Exception e) {

The stack from the RI is:
java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.Socket.connect(Socket.java:520)
	at java.net.Socket.connect(Socket.java:470)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:754)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:626)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:974)

But I'm not sure if we should be attempting a reconnect if end of stream is reached, so I've
just fixed it by throwing a SocketException that the socket has been closed.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message