You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Ulysess Lee 李宇光 <uk...@gmail.com> on 2009/05/20 09:55:57 UTC

About Ftplet session.write 's change

I found that in nest version(1.0.0) , I could not use session.write well as before, like that:
I has a ftplet extends DefaultFtplet ,and in overrided method:beforeCommand I wrote some code to stop some cmds which I would not allow. e.g:

@Override 
public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, 
IOException {
    String command = request.getCommand();
    if (command.toUpperCase().equals("PWD")) {
        session.write(new DefaultFtpReply(202,"Cmd not allowed")); 
    }
    
    ...
    {code for write log in db
    and do some thing here}
    ...    

    return FtpletResult.SKIP;
}

In {code for write log in db and do some thing here} here I want run some code after session write a 202 message to client, but the truth is session.write 's 202 would hold and wait until method return.

I think, In early version this works fine, session.write() will send to client at first time, is there has some change?

Re: About Ftplet session.write 's change

Posted by Niklas Gustavsson <ni...@protocol7.com>.
2009/5/20 Ulysess Lee 李宇光 <uk...@gmail.com>:
> I found that in nest version(1.0.0) , I could not use session.write well as before, like that:
> I has a ftplet extends DefaultFtplet ,and in overrided method:beforeCommand I wrote some code to stop some cmds which I would not allow. e.g:
>
> @Override
> public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException,
> IOException {
>    String command = request.getCommand();
>    if (command.toUpperCase().equals("PWD")) {
>        session.write(new DefaultFtpReply(202,"Cmd not allowed"));
>    }
>
>    ...
>    {code for write log in db
>    and do some thing here}
>    ...
>
>    return FtpletResult.SKIP;
> }
>
> In {code for write log in db and do some thing here} here I want run some code after session write a 202 message to client, but the truth is session.write 's 202 would hold and wait until method return.
>
> I think, In early version this works fine, session.write() will send to client at first time, is there has some change?

FtpSession.write() is merely a wrapper around MINAs IoSession.write
which is asyncronous. Could you please provide some more details on
what you mean by: "but the truth is session.write 's 202 would hold
and wait until method return".

/niklas