JDK-8011234 : Performance regression with ftp protocol when uploading in image mode
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Affected Version: 7,8
  • Submit Date: 2013-04-02
  • Updated Date: 2013-06-26
  • Resolved Date: 2013-04-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b86Resolved
Description
Hi,

A customer is reporting slow Ftp upload in Java 7, versus Java 6.

<<

In our application, we are using URL.openConnection() to open the FTP connection. We would like to know if there is a way to open the buffer Size as mentioned in the URL below or could we do something else to make the ��� java FTP��� file transfer faster ?

http://stackoverflow.com/questions/14000341/why-is-ftp-upload-slow-in-java-7"

>>

The last version tested that does not worked is 7u15. The version
that is working is 6u33.
Solaris 10

No testcase, but here is the snippet:

 URL lUrl = new URL(aInContextURL, aInFtpUrl);
lUrl.openConnection().getOutputStream();

wireshark snippet when using jdk_1.7.0_15  - BAD case

1205826    728.057224    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 220 bytes
1205827    728.059320    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1460 bytes
1205828    728.059327    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1 bytes
1205829    728.059331    135.121.1.60    135.121.1.171    TCP    51748 > 48997 [ACK] Seq=1 Ack=527417331 Win=49640 Len=0
1205830    728.059403    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 14 bytes
1205831    728.061662    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1460 bytes
1205832    728.061668    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1 bytes

1,205,871 packets to send  503M file using ftp

wireshark snippet when using jdk_1.6.0_33  -  GOOD case

50    0.197849    135.121.1.60    135.121.1.23    TCP    25616 > 53511 [ACK] Seq=1 Ack=10221 Win=49640 Len=0
51    0.197965    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
52    0.198089    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
53    0.198211    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
54    0.198334    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes

397,919 packets to send  462M file using ftp


Seeking advice, pointers, further debugging tips.


Thank you,

Kim 
Comments
The ftp URL isn't included in the bug report but I'll bet it image/binary mode. For that case the updated ftp client returns the raw output stream whereas it used to return a TelnetOutputStream (which is buffered). This should fix it: iff -r b4f68aca1000 -r c534937f6e94 src/share/classes/sun/net/ftp/impl/FtpClient.java --- a/src/share/classes/sun/net/ftp/impl/FtpClient.java Tue Apr 02 16:26:54 2013 -0700 +++ b/src/share/classes/sun/net/ftp/impl/FtpClient.java Wed Apr 03 13:15:39 2013 +0100 @@ -1299,16 +1299,16 @@ * <code>null</code> if the command was unsuccessful. * @throws IOException if an error occured during the transmission. */ - public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException { + public OutputStream putFileStream(String name, boolean unique) + throws sun.net.ftp.FtpProtocolException, IOException + { String cmd = unique ? "STOU " : "STOR "; Socket s = openDataConnection(cmd + name); if (s == null) { return null; } - if (type == TransferType.BINARY) { - return s.getOutputStream(); - } - return new sun.net.TelnetOutputStream(s.getOutputStream(), false); + boolean bm = (type == TransferType.BINARY); + return new sun.net.TelnetOutputStream(s.getOutputStream(), bm); } /**
2013-04-02