Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 72191 invoked from network); 19 Jan 2010 10:29:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Jan 2010 10:29:15 -0000 Received: (qmail 62919 invoked by uid 500); 19 Jan 2010 10:29:15 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 62869 invoked by uid 500); 19 Jan 2010 10:29:15 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 62860 invoked by uid 99); 19 Jan 2010 10:29:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jan 2010 10:29:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jan 2010 10:29:14 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6CAFD234C04C for ; Tue, 19 Jan 2010 02:28:54 -0800 (PST) Message-ID: <1629299458.333631263896934443.JavaMail.jira@brutus.apache.org> Date: Tue, 19 Jan 2010 10:28:54 +0000 (UTC) From: "Catherine Hope (JIRA)" To: commits@harmony.apache.org Subject: [jira] Created: (HARMONY-6431) BufferedReader.read() doesn't throw an IOException when an underlying socket is closed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 BufferedReader.read() doesn't throw an IOException when an underlying socket is closed -------------------------------------------------------------------------------------- Key: HARMONY-6431 URL: https://issues.apache.org/jira/browse/HARMONY-6431 Project: Harmony Issue Type: Bug Components: Classlib Affects Versions: 5.0M12 Environment: linux Reporter: Catherine Hope Calling BufferedReader.read() on a socket input stream will block indefinitely if the socket is closed after the read has been called. In this situation the RI behaviour is to throw a java.net.SocketException (subclass of IOException). The problem causes the Eclipse junit runner org.eclipse.jdt.internal.junit.runner.RemoteTestRunner to hang on termination, as it's using a socket.close() to cause a reader thread to shutdown. The problem can be recreated by opening a socket, creating a BufferedReader from the socket input stream, performing a read in another thread and then closing the socket. The problem is caused by the native code doing a blocking read using the system call recv. I can fix the problem easily using the selectRead call which (on linux) using poll to wait on data being available or an exception occurring before calling recv. A better performance solution would be to use the close() to send a signal to any blocked reads on the socket, which is what the RI does. This issue has been discussed previously on a deleted JIRA so I'm raising this one to flag as a known problem. Testcase (don't add as it hangs): /** * @tests java.io.BufferedReader#read() when the underlying socket is closed * during the read */ public void test_read_closed_socket() throws IOException, InterruptedException { ServerSocket ss = new ServerSocket(0); Socket socket = new Socket("", ss.getLocalPort()); br = new BufferedReader(new InputStreamReader(socket.getInputStream())); Thread rt = new Thread(){ public void run() { try { br.read(); } catch (IOException e) { // expected behaviour } } }; rt.start(); // sleep isn't essential but increases likelihood of hang Thread.sleep(100); socket.close(); br.close(); rt.join(); } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.