6919185: test/closed/sun/net/ftp/FtpTests fails to compile

Fixed a couple of regressions in FtpClient and updated the test.

Reviewed-by: chegar
This commit is contained in:
Jean-Christophe Collet 2010-01-26 11:39:29 +01:00
parent 4641ee098b
commit 32443b7f2e

View file

@ -671,6 +671,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
} }
if (!issueCommand(cmd)) { if (!issueCommand(cmd)) {
s.close(); s.close();
if (getLastReplyCode() == FtpReplyCode.FILE_UNAVAILABLE) {
// Ensure backward compatibility
throw new FileNotFoundException(cmd);
}
throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode()); throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode());
} }
return s; return s;
@ -688,7 +692,16 @@ public class FtpClient extends sun.net.ftp.FtpClient {
Socket clientSocket; Socket clientSocket;
if (passiveMode) { 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; ServerSocket portSocket;
InetAddress myAddress; InetAddress myAddress;