Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 25265 invoked from network); 27 Nov 2008 03:27:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Nov 2008 03:27:34 -0000 Received: (qmail 5206 invoked by uid 500); 27 Nov 2008 03:27:45 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 5188 invoked by uid 500); 27 Nov 2008 03:27:45 -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 5178 invoked by uid 99); 27 Nov 2008 03:27:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Nov 2008 19:27:45 -0800 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; Thu, 27 Nov 2008 03:26:27 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 465F6234C2A4 for ; Wed, 26 Nov 2008 19:26:44 -0800 (PST) Message-ID: <1382780311.1227756404286.JavaMail.jira@brutus> Date: Wed, 26 Nov 2008 19:26:44 -0800 (PST) From: "Sean Qiu (JIRA)" To: commits@harmony.apache.org Subject: [jira] Resolved: (HARMONY-6014) [classlib][luni] BufferedInputStream can not be closed in another thread In-Reply-To: <1772064247.1226459984336.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6014?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sean Qiu resolved HARMONY-6014. ------------------------------- Resolution: Fixed But it works :-) Applied at r721075, please verify if it works as expected. > [classlib][luni] BufferedInputStream can not be closed in another thread > ------------------------------------------------------------------------ > > Key: HARMONY-6014 > URL: https://issues.apache.org/jira/browse/HARMONY-6014 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 5.0M7 > Reporter: Kevin Zhou > Assignee: Sean Qiu > Fix For: 5.0M8 > > Attachments: HARMONY-6014.diff, stream.patch > > Original Estimate: 24h > Remaining Estimate: 24h > > Give the following test scenario [1], it start BufferedInputStream object in the main thread, and try to close it in another thread. > HARMONY fails to close it since the main thread can still read bytes from the buffer. > [1] > public void test_BufferedInputStream_close() { > InputStream inputStream = new InputStream() { > Object lock = new Object(); > public int read() { > return 1; > } > public int read(byte[] buf, int offset, int length) { > synchronized (lock) { > try { > lock.wait(3000); > } catch (InterruptedException e) { > // Ignore > } > } > return 1; > } > public void close() { > synchronized (lock) { > lock.notifyAll(); > } > } > }; > final BufferedInputStream buffer = new BufferedInputStream(inputStream); > Runnable runnable = new Runnable() { > public void run() { > try { > Thread.sleep(1000); > buffer.close(); > } catch (Exception e) { > // Ignored > } > } > }; > new Thread(runnable).start(); > try { > buffer.read(new byte[100], 0, 99); > fail("Should throw IOException"); > } catch (IOException e) { > // Expected > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.