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
--- 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;