You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/01/05 19:55:03 UTC
svn commit: r1227754 - in /commons/proper/net/trunk/src: changes/changes.xml
main/java/org/apache/commons/net/ftp/FTPClient.java
Author: sebb
Date: Thu Jan 5 18:55:03 2012
New Revision: 1227754
URL: http://svn.apache.org/viewvc?rev=1227754&view=rev
Log:
NET-434 FTPClient fails to close local listener socket when command socket channel encounter "ReadTimeoutException"
Modified:
commons/proper/net/trunk/src/changes/changes.xml
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1227754&r1=1227753&r2=1227754&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Thu Jan 5 18:55:03 2012
@@ -59,6 +59,9 @@ The <action> type attribute can be add,u
<release version="3.1-SNAPSHOT" date="TBA" description="
TBA
">
+ <action issue="NET-434" dev="sebb" type="fix">
+ FTPClient fails to close local listener socket when command socket channel encounter "ReadTimeoutException"
+ </action>
<action issue="NET-436" dev="sebb" type="add">
Support for SYST "Mac OS" listing - "MACOS Peter's Server"
</action>
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1227754&r1=1227753&r2=1227754&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Thu Jan 5 18:55:03 2012
@@ -688,50 +688,39 @@ implements Configurable
// -> new ServerSocket(0) -> bind to any free local port
ServerSocket server = _serverSocketFactory_.createServerSocket(getActivePort(), 1, getHostAddress());
- // Try EPRT only if remote server is over IPv6, if not use PORT,
- // because EPRT has no advantage over PORT on IPv4.
- // It could even have the disadvantage,
- // that EPRT will make the data connection fail, because
- // today's intelligent NAT Firewalls are able to
- // substitute IP addresses in the PORT command,
- // but might not be able to recognize the EPRT command.
- if (isInet6Address)
- {
- if (!FTPReply.isPositiveCompletion(eprt(getHostAddress(), server.getLocalPort())))
- {
- server.close();
- return null;
+ try {
+ // Try EPRT only if remote server is over IPv6, if not use PORT,
+ // because EPRT has no advantage over PORT on IPv4.
+ // It could even have the disadvantage,
+ // that EPRT will make the data connection fail, because
+ // today's intelligent NAT Firewalls are able to
+ // substitute IP addresses in the PORT command,
+ // but might not be able to recognize the EPRT command.
+ if (isInet6Address) {
+ if (!FTPReply.isPositiveCompletion(eprt(getHostAddress(), server.getLocalPort()))) {
+ return null;
+ }
+ } else {
+ if (!FTPReply.isPositiveCompletion(port(getHostAddress(), server.getLocalPort()))) {
+ return null;
+ }
}
- }
- else
- {
- if (!FTPReply.isPositiveCompletion(port(getHostAddress(), server.getLocalPort())))
- {
- server.close();
+
+ if ((__restartOffset > 0) && !restart(__restartOffset)) {
return null;
}
- }
- if ((__restartOffset > 0) && !restart(__restartOffset))
- {
- server.close();
- return null;
- }
-
- if (!FTPReply.isPositivePreliminary(sendCommand(command, arg)))
- {
- server.close();
- return null;
- }
+ if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) {
+ return null;
+ }
- // For now, let's just use the data timeout value for waiting for
- // the data connection. It may be desirable to let this be a
- // separately configurable value. In any case, we really want
- // to allow preventing the accept from blocking indefinitely.
- if (__dataTimeout >= 0) {
- server.setSoTimeout(__dataTimeout);
- }
- try {
+ // For now, let's just use the data timeout value for waiting for
+ // the data connection. It may be desirable to let this be a
+ // separately configurable value. In any case, we really want
+ // to allow preventing the accept from blocking indefinitely.
+ if (__dataTimeout >= 0) {
+ server.setSoTimeout(__dataTimeout);
+ }
socket = server.accept();
} finally {
server.close();