Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 35915 invoked from network); 11 Jul 2010 12:02:52 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Jul 2010 12:02:52 -0000 Received: (qmail 74319 invoked by uid 500); 11 Jul 2010 12:02:52 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 74015 invoked by uid 500); 11 Jul 2010 12:02:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 73548 invoked by uid 99); 11 Jul 2010 12:02:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 12:02:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 12:02:46 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6BBst3O027866 for ; Sun, 11 Jul 2010 11:54:55 GMT Message-ID: <10007912.314681278849295758.JavaMail.jira@thor> Date: Sun, 11 Jul 2010 07:54:55 -0400 (EDT) From: "Sebb (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (NET-46) [net] retrieveFileStream fails randomly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-46?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb updated NET-46: -------------------- Component/s: FTP > [net] retrieveFileStream fails randomly > --------------------------------------- > > Key: NET-46 > URL: https://issues.apache.org/jira/browse/NET-46 > Project: Commons Net > Issue Type: Bug > Components: FTP > Affects Versions: 1.4 > Environment: Operating System: Windows XP > Platform: PC > Reporter: Dennis Meerveld > > 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. - You can reply to this email to add a comment to the issue online.