提交 e536b08b 编写于 作者: R rpatil

8170222: Better transfers of files

Reviewed-by: dfuchs, chegar, vtewari
上级 a42bcab5
/* /*
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -517,7 +517,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -517,7 +517,8 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @return <code>true</code> if the command was successful * @return <code>true</code> if the command was successful
* @throws IOException * @throws IOException
*/ */
private boolean issueCommand(String cmd) throws IOException { private boolean issueCommand(String cmd) throws IOException,
sun.net.ftp.FtpProtocolException {
if (!isConnected()) { if (!isConnected()) {
throw new IllegalStateException("Not connected"); throw new IllegalStateException("Not connected");
} }
...@@ -528,6 +529,12 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -528,6 +529,12 @@ public class FtpClient extends sun.net.ftp.FtpClient {
// ignore... // ignore...
} }
} }
if (cmd.indexOf('\n') != -1) {
sun.net.ftp.FtpProtocolException ex
= new sun.net.ftp.FtpProtocolException("Illegal FTP command");
ex.initCause(new IllegalArgumentException("Illegal carriage return"));
throw ex;
}
sendServer(cmd + "\r\n"); sendServer(cmd + "\r\n");
return readReply(); return readReply();
} }
...@@ -1120,7 +1127,10 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -1120,7 +1127,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
*/ */
public void close() throws IOException { public void close() throws IOException {
if (isConnected()) { if (isConnected()) {
issueCommand("QUIT"); try {
issueCommand("QUIT");
} catch (FtpProtocolException e) {
}
loggedIn = false; loggedIn = false;
} }
disconnect(); disconnect();
...@@ -1898,7 +1908,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -1898,7 +1908,8 @@ public class FtpClient extends sun.net.ftp.FtpClient {
return null; return null;
} }
private boolean sendSecurityData(byte[] buf) throws IOException { private boolean sendSecurityData(byte[] buf) throws IOException,
sun.net.ftp.FtpProtocolException {
BASE64Encoder encoder = new BASE64Encoder(); BASE64Encoder encoder = new BASE64Encoder();
String s = encoder.encode(buf); String s = encoder.encode(buf);
return issueCommand("ADAT " + s); return issueCommand("ADAT " + s);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册