You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2011/05/06 20:50:47 UTC

DO NOT REPLY [Bug 51161] New: Stream Closed error in DefaultInputHandler with embedded ant task

https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

             Bug #: 51161
           Summary: Stream Closed error in DefaultInputHandler with
                    embedded ant <input> task
           Product: Ant
           Version: 1.8.1
          Platform: Macintosh
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: kldavis4@gmail.com
    Classification: Unclassified


I am using the maven-antrun-plugin 1.6 with the <input> task and the default
input handler. When I enter input, it throws a BuildException, "Failed to read
input from Console". The root exception is:


java.io.IOException: Stream closed
        at
java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:145)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:308)
        at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
        at java.io.InputStreamReader.read(InputStreamReader.java:167)
        at java.io.BufferedReader.fill(BufferedReader.java:136)
        at java.io.BufferedReader.readLine(BufferedReader.java:299)
        at java.io.BufferedReader.readLine(BufferedReader.java:362)


I was able to fix this issue by wrapping the input stream in
KeepAliveInputStream as follows:

    public void handleInput(InputRequest request) throws BuildException {
        String prompt = getPrompt(request);
        BufferedReader r = null;
        try {
            r = new BufferedReader(new InputStreamReader(new
KeepAliveInputStream(getInputStream())));
            do {
                System.err.print(prompt + ": ");
                System.err.flush();
                try {
                    String input = r.readLine();
                    request.setInput(input);
                } catch (IOException e) {
                    throw new BuildException("Failed to read input from"
                                             + " Console.", e);
                }
            } while (!request.isInputValid());
        } finally {
            if (r != null) {
                try {
                    r.close();
                } catch (IOException e) {
                    throw new BuildException("Failed to close input.", e);
                }
            }
        }
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51161] Stream Closed error in DefaultInputHandler with embedded ant task

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

Nicolas Lalevée <ni...@hibnet.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nicolas.lalevee@hibnet.org
         OS/Version|                            |All

--- Comment #1 from Nicolas Lalevée <ni...@hibnet.org> 2011-06-08 08:41:14 UTC ---
I am not that used to write pom.xml file. Could you provide a piece of pom.xml
which reproduce the bug please ?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51161] Stream Closed error in DefaultInputHandler with embedded ant task

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

--- Comment #4 from Kelly Davis <kl...@gmail.com> 2011-07-26 18:33:43 UTC ---
Ok, sorry about that. If you run 'mvn generate-sources' it doesn't run the ant
plugin. Please run it with 'mvn compile'. That should trigger the problem.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51161] Stream Closed error in DefaultInputHandler with embedded ant task

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

--- Comment #3 from Nicolas Lalevée <ni...@hibnet.org> 2011-07-24 11:54:32 UTC ---
Sorry for the late follow up, but I cannot reproduce the error. I tried with
both maven 2 and maven 3. Here is what I got:

hibou@hibpro ~/dev/ant/svn/core/trunk/tmp $ mvn generate-sources       
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.135s
[INFO] Finished at: Sun Jul 24 13:52:29 CEST 2011
[INFO] Final Memory: 2M/81M
[INFO] ------------------------------------------------------------------------
hibou@hibpro ~/dev/ant/svn/core/trunk/tmp $ mvn2 generate-sources      
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Test
[INFO]    task-segment: [generate-sources]
[INFO] ------------------------------------------------------------------------
[INFO] No goals needed for project - skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sun Jul 24 13:52:36 CEST 2011
[INFO] Final Memory: 2M/81M
[INFO] ------------------------------------------------------------------------

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51161] Stream Closed error in DefaultInputHandler with embedded ant task

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

Nicolas Lalevée <ni...@hibnet.org> changed:

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

--- Comment #5 from Nicolas Lalevée <ni...@hibnet.org> 2011-07-26 22:03:09 UTC ---
reproduced and fixed. Thanks for your report.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 51161] Stream Closed error in DefaultInputHandler with embedded ant task

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51161

--- Comment #2 from Kelly Davis <kl...@gmail.com> 2011-06-08 12:17:30 UTC ---
The following pom will generate the error:


<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.help</groupId>
    <artifactId>Test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Test</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>configure-resources</id>
                        <phase>generate-resources</phase>
                        <configuration>
                            <target>
                                <input message="Enter Foo Property"
addproperty="foo.property" defaultvalue="FOO"/>
                                <input message="Enter Bar Property"
addproperty="bar.property" defaultvalue="BAR"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

execute 'mvn generate-sources'

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.