commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35863] New: - retrieveFileStream fails randomly
Date Tue, 26 Jul 2005 09:59:48 GMT
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=35863>.
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=35863

           Summary: retrieveFileStream fails randomly
           Product: Commons
           Version: 1.4 Final
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Net
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: dennis.meerveld@ubench.com


For my application I need a way to get the InputStream of a binary file on a
FTPServer. What I did was :

// connect and get ftpFiles as an array
// for each ftpFile ...

InputStream is = ftp.retrieveFileStream(ftpFiles[i].getName());

However, this behaves erratically : sometimes the inputstream is correct and
sometimes it is null (and the ftpFile exists, no weird name or anything odd
about it).

After first blaming my FTPServer (I use GuildFTPd 0.9.9.13) I tried another
FTPServer (Serv-U 6.1), but this also had the same behavior. 

Then I thought I might have to do with timing. So I tried Thread.sleep(xxx) on a
couple of locations but to no avail. In a last attempt (was getting pretty
desperate :) ) I rewrote my original line and replaced it by this :

ByteArrayOutputStream out = new ByteArrayOutputStream();
ftp.retrieveFile(ftpFiles[i].getName(),out);
InputStream is = new ByteArrayInputStream(out.toByteArray());

And much to my surprise, it worked like a charm. Tested it a couple of times (on
both FTPServer products) and works perfectly.

So I'm guessing something is going wrong in your retrieveFileStream
implementation. Maybe something worth looking into ? (easiest fix : use the
ByteArrayOut/InputStream swap :)).

kind regards,

Dennis

-- 
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message