harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3347) [classlib] [io] ant exec.redirector is unstable while works on HDK
Date Mon, 14 May 2007 13:50:16 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495598
] 

Mikhail Markov commented on HARMONY-3347:
-----------------------------------------

I've instrumented ant code and found that ant caught IOException (in org.apache.tools.ant.taskdefs.StreamPumper
class) from PipedInputStream with "Pipe broken" message.

Here is a piece of code from PipedInputStream method throwing "Pipe broken" IOException:
...
            boolean first = true;
            while (in == -1) {
                // Are we at end of stream?
                if (isClosed) {
                    return -1;
                }
                if (!first && lastWriter != null && !lastWriter.isAlive())
{
                    throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
                }
                first = false;
                // Notify callers of receive()
                notifyAll();
                wait(1000);
            }
...
So, to avoid infinite waits, if writer thread (i.e. the thread writing to PipedOutputStream)
is not alive, then PipedInputStream will wait max 1 sec for stream to be closed and will throw
IOException with "Pipe broken" message.

I've added debug prints to PipedInputStream and found that indeed there are 3 threads working
with Piped in/out streams: 1-st writes to the stream (writer), 2-nd reads from the stream
(reader) and 3-rd closes the stream (seems like this is a system thread, which is spawned
when Runtime.exec() method is called for running "svn". The problem is that the gap between
writer thread became not alive and the moment when closing thread actually closes the thread
is more that 1 sec.
I've black-box tested RI's logic and found that it waits 3 sec before throwing IOException
"Pipe broken".

If i add 1 more sec of waiting then the ant starts working:
...
            int attempts = 2;
            while (in == -1) {
                // Are we at end of stream?
                if (isClosed) {
                    return -1;
                }
                if ((attempts-- <= 0) && lastWriter != null && !lastWriter.isAlive())
{
                    throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
                }
                // Notify callers of receive()
                notifyAll();
                wait(1000);
            }
...

So, in my opinion it makes sense to also add more iterations of waiting (perhaps, at least
the same time as in RI, i.e. the number of attempts in the code above should be 3). On some
slow machines, perhaps, the code might still fails but generally it becomes more robust.

> [classlib] [io] ant exec.redirector is unstable while works on HDK
> ------------------------------------------------------------------
>
>                 Key: HARMONY-3347
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3347
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports
>            Reporter: Vladimir Ivanov
>         Attachments: my_build.xml
>
>
> The build of HDK sometimes failed when it run over HDK because can't define the svn revision.
> For me it report 'no revision' ~ 2times for 5 runs.
> The execution log is:
> harmony\trunk>build_sf.bat
> Setting environment for using Microsoft Visual Studio .NET 2003 tools.
> (If you have another version of Visual Studio or Visual C++ installed and wish
> to use its tools from the command line, run vcvars32.bat for that version.)
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or
its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r516383, (Mar  9 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Buildfile: build.xml
> svn-prop:
> init:
> show_props:
>      [echo]
>      [echo]                    Apache Harmony Federated Build
>      [echo]             ==========================================
>      [echo]             svn rev          :  r516383
>      [echo]             operating system :  windows
>      [echo]             architecture     :  x86-32
>      [echo]             ant os name/arch :  Windows XP/x86
>      [echo]             output location  :  target
>      [echo]             DRLVM classlib   :  ../../../working_classlib
>      [echo]
> <...>
> harmony\trunk>build_sf.bat
> Setting environment for using Microsoft Visual Studio .NET 2003 tools.
> (If you have another version of Visual Studio or Visual C++ installed and wish
> to use its tools from the command line, run vcvars32.bat for that version.)
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or
its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r516383, (Mar  9 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Buildfile: build.xml
> svn-prop:
> init:
> show_props:
>      [echo]
>      [echo]                    Apache Harmony Federated Build
>      [echo]             ==========================================
>      [echo]             svn rev          :  r
>      [echo]             operating system :  windows
>      [echo]             architecture     :  x86-32
>      [echo]             ant os name/arch :  Windows XP/x86
>      [echo]             output location  :  target
>      [echo]             DRLVM classlib   :  ../../../working_classlib
>      [echo]
> BUILD FAILED

-- 
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