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 2010/09/20 18:29:26 UTC
svn commit: r998992 - in /commons/proper/net/trunk/src: changes/changes.xml
main/java/org/apache/commons/net/ftp/FTPClient.java
Author: sebb
Date: Mon Sep 20 16:29:26 2010
New Revision: 998992
URL: http://svn.apache.org/viewvc?rev=998992&view=rev
Log:
NET-338: ftp.FTPClient.initiateListParsing(String parserKey, String pathname) can call createFileEntryParser with null systemName
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=998992&r1=998991&r2=998992&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Mon Sep 20 16:29:26 2010
@@ -61,6 +61,11 @@ This is primarily a maintenance release,
TO BE COMPLETED
">
+ <action issue="NET-338" dev="sebb" type="add">
+ ftp.FTPClient.initiateListParsing(String parserKey, String pathname)
+ can call createFileEntryParser with null systemName.
+ Fix this by adding getSystemType() which does not return null, and deprecating getSystemName().
+ </action>
<action issue="NET-244" dev="sebb" type="add">
Add support for FTPFileFilter filters. New classes FTPFileFilter, FTPFileFilters, new methods:
FTPListParseEngine#getFiles(FTPFileFilter filter)
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=998992&r1=998991&r2=998992&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 Mon Sep 20 16:29:26 2010
@@ -2024,7 +2024,9 @@ implements Configurable
* as an IOException or independently as itself.
* @exception IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
+ * @deprecated Use {@link #getSystemType()} - which does not return null
***/
+ @Deprecated
public String getSystemName() throws IOException
{
//if (syst() == FTPReply.NAME_SYSTEM_TYPE)
@@ -2039,6 +2041,41 @@ implements Configurable
/***
+ * Fetches the system type from the server and returns the string.
+ * This value is cached for the duration of the connection after the
+ * first call to this method. In other words, only the first time
+ * that you invoke this method will it issue a SYST command to the
+ * FTP server. FTPClient will remember the value and return the
+ * cached value until a call to disconnect.
+ * <p>
+ * @return The system type obtained from the server. Never null.
+ * @exception FTPConnectionClosedException
+ * If the FTP server prematurely closes the connection as a result
+ * of the client being idle or some other reason causing the server
+ * to send FTP reply code 421. This exception may be caught either
+ * as an IOException or independently as itself.
+ * @exception IOException If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
+ ***/
+ public String getSystemType() throws IOException
+ {
+ //if (syst() == FTPReply.NAME_SYSTEM_TYPE)
+ // Technically, we should expect a NAME_SYSTEM_TYPE response, but
+ // in practice FTP servers deviate, so we soften the condition to
+ // a positive completion.
+ if (__systemName == null){
+ if (FTPReply.isPositiveCompletion(syst())) {
+ // Assume that response is not empty here (cannot be null)
+ __systemName = _replyLines.get(_replyLines.size() - 1).substring(4);
+ } else {
+ throw new IOException("Unable to determine system type - response: " + getReplyString());
+ }
+ }
+ return __systemName;
+ }
+
+
+ /***
* Fetches the system help information from the server and returns the
* full string.
* <p>
@@ -2463,10 +2500,10 @@ implements Configurable
// if a parserKey hasn't been supplied, and a configuration
// hasn't been supplied, then autodetect by calling
// the SYST command and use that to choose the parser.
- final String systemName = getSystemName();
+ final String systemType = getSystemType(); // cannot be null
__entryParser =
- __parserFactory.createFileEntryParser(systemName);
- __entryParserKey = systemName;
+ __parserFactory.createFileEntryParser(systemType);
+ __entryParserKey = systemType;
}
}
}