[ 
https://issues.apache.org/jira/browse/NET-46?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sebb resolved NET-46.
---------------------

       Resolution: Fixed
    Fix Version/s: 3.2

URL: http://svn.apache.org/viewvc?rev=1413545&view=rev
Log:
NET-46 retrieveFileStream fails randomly or hangs

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
                
> retrieveFileStream fails randomly or hangs
> ------------------------------------------
>
>                 Key: NET-46
>                 URL: https://issues.apache.org/jira/browse/NET-46
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 1.4, 3.1
>         Environment: Operating System: Windows XP
> Platform: PC
>            Reporter: Dennis Meerveld
>             Fix For: 3.2
>
>
> 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

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to