You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/11/20 15:02:50 UTC
svn commit: r1847018 - in /commons/proper/vfs/trunk:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java
src/changes/changes.xml
Author: ggregory
Date: Tue Nov 20 15:02:50 2018
New Revision: 1847018
URL: http://svn.apache.org/viewvc?rev=1847018&view=rev
Log:
[VFS-674] Cannot close an FTP input stream without an exception. Closes #41. Changed patch from Boris Petrov to avoid breaking binary compatibility.
Modified:
commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java
commons/proper/vfs/trunk/src/changes/changes.xml
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java?rev=1847018&r1=1847017&r2=1847018&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClient.java Tue Nov 20 15:02:50 2018
@@ -21,12 +21,14 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.vfs2.FileSystemException;
/**
- * What VFS expects from an ftp client to provide.
+ * What VFS expects from an FTP client to provide.
*/
public interface FtpClient {
+
boolean isConnected() throws FileSystemException;
void disconnect() throws IOException;
@@ -54,4 +56,9 @@ public interface FtpClient {
boolean abort() throws IOException;
String getReplyString() throws IOException;
+
+ default int getReplyCode() throws IOException {
+ return FTPReply.COMMAND_OK;
+ }
+
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java?rev=1847018&r1=1847017&r2=1847018&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java Tue Nov 20 15:02:50 2018
@@ -29,6 +29,7 @@ import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.vfs2.FileName;
import org.apache.commons.vfs2.FileNotFolderException;
import org.apache.commons.vfs2.FileObject;
@@ -582,7 +583,8 @@ public class FtpFileObject extends Abstr
protected void onClose() throws IOException {
final boolean ok;
try {
- ok = client.completePendingCommand();
+ // See VFS-674 and the accompanying PR as to why this check for "transfer aborted" is needed
+ ok = client.completePendingCommand() || client.getReplyCode() == FTPReply.TRANSFER_ABORTED;
} finally {
getAbstractFileSystem().putClient(client);
}
Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1847018&r1=1847017&r2=1847018&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Tue Nov 20 15:02:50 2018
@@ -101,6 +101,9 @@ The <action> type attribute can be add,u
<action issue="VFS-681" dev="ggregory" type="update" due-to="Robert DeRose">
VFS.setManager should be synchronized; #43.
</action>
+ <action issue="VFS-674" dev="ggregory" type="fix" due-to="Boris Petrov, Gary Gregory">
+ Cannot close an FTP input stream without an exception.
+ </action>
</release>
<release version="2.2" date="2017-10-06" description="New features and bug fix release.">
<action issue="VFS-642" dev="pschumacher" type="update" due-to="ilangoldfeld">