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

http://issues.apache.org/bugzilla/show_bug.cgi?id=35255

           Summary: davget ANT task downloads files with size 0 on slow
                    connections
           Product: Slide
           Version: 2.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: WebDAV client
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


The org.apache.webdav.ant.taskdefs.Get.copyStream(InputStream, OutputStream, 
FilterSetCollection, String) method uses java.io.InputStream.available() in 
order to determine the number of bytes to be read from the stream.

According to the documentation of java.io.InputStream.available() this 
method "Returns the number of bytes that can be read (or skipped over) from 
this input stream without blocking by the next caller of a method for this 
input stream. The next caller might be the same thread or or another thread."

As a result all downloaded files will have the size 0 if a slow connection is 
used.

Suggested solution:
Replace the existing code:
    while (in.available() > 0) {
        int cnt = in.read(b, 0, b.length);
        if (cnt > -1) {
            out.write(b, 0, cnt);
        }
    }
by:
    int cnt;
    while ((cnt = in.read(b, 0, b.length)) > 0)
    {
        out.write(b, 0, cnt);
    }
in order to read the stream until the end of the stream has been reached.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to