changeset 2111:f544825d0976

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 558f2a424bfa
children 8df0ffac7f4d
files src/share/classes/sun/net/ftp/impl/FtpClient.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/ftp/impl/FtpClient.java	Tue Jan 26 17:03:48 2010 +0800
+++ b/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;