6919185: test/closed/sun/net/ftp/FtpTests fails to compile
authorjccollet
Tue, 26 Jan 2010 11:39:29 +0100
changeset 4813 654ff751c112
parent 4812 c3da56ecc260
child 4814 dbf72872f8d2
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
jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java
--- 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;