From 32443b7f2e97aaa6e128f45fe80b89c86d9e564b Mon Sep 17 00:00:00 2001 From: Jean-Christophe Collet Date: Tue, 26 Jan 2010 11:39:29 +0100 Subject: [PATCH] 6919185: test/closed/sun/net/ftp/FtpTests fails to compile Fixed a couple of regressions in FtpClient and updated the test. Reviewed-by: chegar --- .../share/classes/sun/net/ftp/impl/FtpClient.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java index 31fe2ba61a4..bc4e48819f6 100644 --- a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java @@ -671,6 +671,10 @@ public class FtpClient extends sun.net.ftp.FtpClient { } 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 @@ public class FtpClient extends sun.net.ftp.FtpClient { 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;