commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John B (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NET-291) enterLocalPassiveMode is set back to Active on connect
Date Thu, 02 Feb 2012 23:58:53 GMT

    [ https://issues.apache.org/jira/browse/NET-291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199381#comment-13199381
] 

John B commented on NET-291:
----------------------------

With version 3.1 I'm still getting the problem "active mode is being entered after connect
is called", Once I fixed that issue it connected but was not able to make data connections.

1) FTPHTTPClient still needs to force passive mode until the offending code in FTPClient that
resets to active mode is fixed (maybe it used to do this?). 2) FTPHTTPClient overrides _openDataConnection_(String,String)
but should override _openDataConnection_(int,String) instead because in the parent class the
(int,Str) version just converts the first arg to a Str and calls the (Str,Str) version.  Doing
this allows the subclass to capture both versions and make the needed behaviour change for
Proxied connections.

Patch is

diff -wu .orig/FTPHTTPClient.java FTPHTTPClient.java 
--- .orig/FTPHTTPClient.java	Wed Feb  1 14:57:41 2012
+++ FTPHTTPClient.java	Thu Feb  2 14:05:50 2012
@@ -63,11 +63,11 @@
      * @throws IllegalStateException if connection mode is not passive
      */
     @Override
-    protected Socket _openDataConnection_(int command, String arg) 
+    protected Socket _openDataConnection_(String command, String arg) 
     throws IOException {
         //Force local passive mode, active mode not supported by through proxy
         if (getDataConnectionMode() != PASSIVE_LOCAL_DATA_CONNECTION_MODE) {
-            throw new IllegalStateException("Only passive connection mode supported");
+            enterLocalPassiveMode();
         }
 

                
> enterLocalPassiveMode is set back to Active on connect
> ------------------------------------------------------
>
>                 Key: NET-291
>                 URL: https://issues.apache.org/jira/browse/NET-291
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.0
>            Reporter: Kevin Brown
>             Fix For: 3.1
>
>
> enterLocalPassiveMode (exhibit A) docs claim that mode will be set to PASSIVE_LOCAL_DATA_CONNECTION_MODE
"some other method such as" enterLocalActiveMode is called  (exhibit B).  However, active
mode is being entered after connect is called.   This behavior can be easily observed by modifying
FtpExample by moving ftp.enterLocalPassiveMode()  to before ftp.connect(server).   
> Perhaps either the code or docs could be updated to remedy this.  Versions prior to 2.0
behaved as documented.
>  
> exhibit A:
>    /***
>      * Set the current data connection mode to
>      * <code> PASSIVE_LOCAL_DATA_CONNECTION_MODE </code>.  Use this
>      * method only for data transfers between the client and server.
>      * This method causes a PASV command to be issued to the server
>      * before the opening of every data connection, telling the server to
>      * open a data port to which the client will connect to conduct
>      * data transfers.  The FTPClient will stay in
>      * <code> PASSIVE_LOCAL_DATA_CONNECTION_MODE </code> until the
>      * mode is changed by calling some other method such as
>      * {@link #enterLocalActiveMode  enterLocalActiveMode() }
>      ***/
>     public void enterLocalPassiveMode()
>     {
>         __dataConnectionMode = PASSIVE_LOCAL_DATA_CONNECTION_MODE;
>         // These will be set when just before a data connection is opened
>         // in _openDataConnection_()
>         __passiveHost = null;
>         __passivePort = -1;
>     }
> exhibit B
>     @Override
>     protected void _connectAction_() throws IOException
>     {
>         super._connectAction_();
>         __initDefaults();
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message