changeset 4813:654ff751c112

6919185: test/closed/sun/net/ftp/FtpTests fails to compile Summary: Fixed a couple of regressions in FtpClient and updated the test. Reviewed-by: chegar
author jccollet
date Tue, 26 Jan 2010 11:39:29 +0100
parents c3da56ecc260
children dbf72872f8d2
files jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java	Tue Jan 26 17:03:48 2010 +0800
+++ b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java	Tue Jan 26 11:39:29 2010 +0100
@@ -671,6 +671,10 @@
         }
         if (!issueCommand(cmd)) {
             s.close();
+            if (getLastReplyCode() == FtpReplyCode.FILE_UNAVAILABLE) {
+                // Ensure backward compatibility
+                throw new FileNotFoundException(cmd);
+            }
             throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode());
         }
         return s;
@@ -688,7 +692,16 @@
         Socket clientSocket;
 
         if (passiveMode) {
-            return openPassiveDataConnection(cmd);
+            try {
+                return openPassiveDataConnection(cmd);
+            } catch (sun.net.ftp.FtpProtocolException e) {
+                // If Passive mode failed, fall back on PORT
+                // Otherwise throw exception
+                String errmsg = e.getMessage();
+                if (!errmsg.startsWith("PASV") && !errmsg.startsWith("EPSV")) {
+                    throw e;
+                }
+            }
         }
         ServerSocket portSocket;
         InetAddress myAddress;