You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2003/08/12 16:04:55 UTC

DO NOT REPLY [Bug 22347] - java task with BufferedReader hangs

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22347>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22347

java task with BufferedReader hangs

conor@cortexebusiness.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |1.6



------- Additional Comments From conor@cortexebusiness.com.au  2003-08-12 14:04 -------
I presume you are forking the <java> task. Your code should work if you don't
fork since you will then access System.in of the Ant VM. When forked, the <java>
task is run in a separate VM and no input is provided to this VM. Any attempt to
read input will hang that VM waiting for input that is never going to arrive.
The input you are typing is going to Ant's VM, not the one running your Java
code. The Ant VM isn't trying to read it's input, it's waiting for the external
VM to finish. The end result is that everything hangs.

Ant 1.6 has much better input handling. By default when forked, the external
VM's input stream is closed so that any attempts to read input will fail fast -
i.e. it won't hang. Your readLine will return null. You may, however, provide
input to the task from a file or an Ant property. 

It is not possible to connect the console to the forked <java> task in the
external VM. i.e. You cannot type into console and have that input provided to
the external VM. In general achieving this would be difficult given that more
than one task may be running in parallel and there is no way to know how much
input each task will want.

Finally Ant 1.6 adds a -noinput flag. This prevents even non-forked <java> tasks
from reading input. This can be useful if you don't want to inadvertently hang
an unattended Ant operation (say a continuous integration type of run).

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org