harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (HARMONY-6014) [classlib][luni] BufferedInputStream can not be closed in another thread
Date Thu, 04 Dec 2008 05:14:44 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6014?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sean Qiu reopened HARMONY-6014:
-------------------------------

      Assignee: Tim Ellison  (was: Sean Qiu)

This issue hasn't been completed fixed yet.
Need more investigation.

> [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: Tim Ellison
>             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.


Mime
View raw message