Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E5ACD3AB for ; Thu, 12 Jul 2012 23:43:24 +0000 (UTC) Received: (qmail 85150 invoked by uid 500); 12 Jul 2012 23:43:24 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 85101 invoked by uid 500); 12 Jul 2012 23:43:24 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 85088 invoked by uid 99); 12 Jul 2012 23:43:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2012 23:43:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2012 23:43:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id ED78B23888EA for ; Thu, 12 Jul 2012 23:43:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1361003 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTPClient.java Date: Thu, 12 Jul 2012 23:43:00 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120712234300.ED78B23888EA@eris.apache.org> Author: sebb Date: Thu Jul 12 23:43:00 2012 New Revision: 1361003 URL: http://svn.apache.org/viewvc?rev=1361003&view=rev Log: NET-465 FTPClient setSendBufferSize and setReceiveBufferSize on data socket Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Modified: commons/proper/net/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1361003&r1=1361002&r2=1361003&view=diff ============================================================================== --- commons/proper/net/trunk/src/changes/changes.xml (original) +++ commons/proper/net/trunk/src/changes/changes.xml Thu Jul 12 23:43:00 2012 @@ -65,6 +65,9 @@ The type attribute can be add,u + + FTPClient setSendBufferSize and setReceiveBufferSize on data socket. + FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP. Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1361003&r1=1361002&r2=1361003&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Thu Jul 12 23:43:00 2012 @@ -592,7 +592,7 @@ implements Configurable return false; } - OutputStream output = new BufferedOutputStream(socket.getOutputStream(), getBufferSize()); + OutputStream output = new BufferedOutputStream(socket.getOutputStream(), getDefaultedBufferSize()); if (__fileType == ASCII_FILE_TYPE) { output = new ToNetASCIIOutputStream(output); @@ -606,7 +606,7 @@ implements Configurable // Treat everything else as binary for now try { - Util.copyStream(local, output, getBufferSize(), + Util.copyStream(local, output, getDefaultedBufferSize(), CopyStreamEvent.UNKNOWN_STREAM_SIZE, __mergeListeners(csl), false); } @@ -651,7 +651,7 @@ implements Configurable // own if they want to wrap the SocketOutputStream we return // for file types other than ASCII. output = new BufferedOutputStream(output, - getBufferSize()); + getDefaultedBufferSize()); output = new ToNetASCIIOutputStream(output); } @@ -815,6 +815,11 @@ implements Configurable socket.setSoTimeout(__dataTimeout); } + if ( __bufferSize > 0 ) { + socket.setReceiveBufferSize(__bufferSize); + socket.setSendBufferSize(__bufferSize); + } + return socket; } @@ -1744,7 +1749,7 @@ implements Configurable } InputStream input = new BufferedInputStream(socket.getInputStream(), - getBufferSize()); + getDefaultedBufferSize()); if (__fileType == ASCII_FILE_TYPE) { input = new FromNetASCIIInputStream(input); } @@ -1757,7 +1762,7 @@ implements Configurable // Treat everything else as binary for now try { - Util.copyStream(input, local, getBufferSize(), + Util.copyStream(input, local, getDefaultedBufferSize(), CopyStreamEvent.UNKNOWN_STREAM_SIZE, __mergeListeners(csl), false); } finally { @@ -1823,7 +1828,7 @@ implements Configurable // own if they want to wrap the SocketInputStream we return // for file types other than ASCII. input = new BufferedInputStream(input, - getBufferSize()); + getDefaultedBufferSize()); input = new FromNetASCIIInputStream(input); } return new org.apache.commons.net.io.SocketInputStream(socket, input); @@ -3309,22 +3314,29 @@ implements Configurable /** - * Set the internal buffer size. + * Set the internal buffer size for data sockets. * - * @param bufSize The size of the buffer + * @param bufSize The size of the buffer. Use a non-positive value to use the default. */ public void setBufferSize(int bufSize) { __bufferSize = bufSize; } /** - * Retrieve the current internal buffer size. + * Retrieve the current internal buffer size for data sockets. * @return The current buffer size. */ public int getBufferSize() { return __bufferSize; } + /** + * Get the buffer size, with default set to Util.DEFAULT_COPY_BUFFER_SIZE. + * @return the buffer size. + */ + private int getDefaultedBufferSize() { + return __bufferSize > 0 ? __bufferSize : Util.DEFAULT_COPY_BUFFER_SIZE; + } /** * Implementation of the {@link Configurable Configurable} interface.