You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org> on 2006/11/16 23:41:37 UTC

[jira] Created: (JAMES-700) James resets connection when command throws RuntimeException

James resets connection when command throws RuntimeException
------------------------------------------------------------

                 Key: JAMES-700
                 URL: http://issues.apache.org/jira/browse/JAMES-700
             Project: James
          Issue Type: Improvement
          Components: IMAPServer
            Reporter: Robert Burrell Donkin
             Fix For: Trunk


I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org>.
    [ http://issues.apache.org/jira/browse/JAMES-700?page=comments#action_12450565 ] 
            
Robert Burrell Donkin commented on JAMES-700:
---------------------------------------------

I had a patch for this but I'm not sure it's right. Need to think a little more on this.

> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Joachim Draeger (JIRA)" <se...@james.apache.org>.
    [ http://issues.apache.org/jira/browse/JAMES-700?page=comments#action_12450662 ] 
            
Joachim Draeger commented on JAMES-700:
---------------------------------------


IMAP actually has four states (pre auth, auth, selected, logout). 
In the selected state the client can rely on message number stability.
The protocol assumes that client and server are in sync.

At the moment the whole construct of server and backend is quite fragile. Exceptions may thrown for different reasons: bug in server/bug in backend/real IO problem or a misbehaving client.

So we have to differentiate carefully the reason for the error.

IMO the following makes sense:

1. Real IO error
 * the server is probably in big problems. No assumption can be made if and how the session can go on
 -> rest connection

2. Bug on the server side
 * No assumption can be made if the session is still valid and if client and server are still in sync
 -> rest connection

3. Misbehaving client.
 * we should be able to validate the client request before doing any actions
 -> send a BAD response

4. unsupported feature
* we should be able to detect this before any action is taken 
-> send a BAD/NO response

5. the client requested something not existing (folder/messages)
* the RFCs make proposals whether the action could be performed partial or should rejected completely 
-> send a corresponding response

There are very likely still situations of 3.-5. that are not handled correctly, I consider them as bugs.

Please don't hesitate to throw in your ideas/patches. It could be a nice thing to have "reset connection" configurable, and see how the clients react to it.

The problem is that we have to see how the clients react and can't rely completely on RFCs. (There are a lot of "shoulds" ;-)


> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org>.
    [ http://issues.apache.org/jira/browse/JAMES-700?page=comments#action_12451059 ] 
            
Robert Burrell Donkin commented on JAMES-700:
---------------------------------------------

IMAP is a very tough protocol (IMO too complex but maybe more on that another time) so kudos to having got so far

in definite agreement about 1, 3, 4, 5

RE: 2 

here's my symptoms:

sending a reset to the client means that the client will restart it's entire program up to where it left off. so, a single bug in a single command results in an uninformative error message being displayed (connection reset by peer) followed by a new connection and the whole process starts again from scratch. this results in the client becoming effectively unusable until killed.

i've now tracked down the problem by studying the code but I fear that rule 2 is too harsh for most clients and most users.

i've been running with catching all RuntimeException's thrown by any command and this works very well for me. i'll add some configuration and attach a patch for this since it'll probably be useful for anyone else who's using IMAP ATM.

but i agree 

2alt. * assume that client can recover and send a NO with error message

is probably not a good idea

i think that it should be possible to work out from the command whether it's reasonably safe to send a NO or not. 

so the rule would be:

2new. * for safe commands, send a NO; for unsafe commands send reset

for example, perhaps (where reset means reset the connection, swallow mean ignore the error and NO means send a NO with message)

CAPABILITY Command - reset
NOOP Command - swallow
LOGOUT Command - reset 
AUTHENTICATE Command - NO 
LOGIN Command - NO
SELECT Command - reset?
EXAMINE Command - NO
CREATE Command - NO
DELETE Command - NO
RENAME Command - NO
SUBSCRIBE Command - reset
UNSUBSCRIBE Command - reset
LIST Command - NO
LSUB Command - reset
STATUS Command - NO
APPEND Command - NO
CHECK Command - reset
CLOSE Command - NO?
EXPUNGE Command - NO
SEARCH Command - NO
FETCH Command - NO
STORE Command - NO
COPY Command - NO
UID Command - NO


> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Updated: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org>.
     [ http://issues.apache.org/jira/browse/JAMES-700?page=all ]

Robert Burrell Donkin updated JAMES-700:
----------------------------------------

    Attachment: james-imap-runtime-catch.patch

This is the effective patch I'm running on my local James fork. This corresponds to the no-reset version. This has made a big difference to my local stability: before, James IMAP was effectively unusable for my data set. 

However, I agree that it isn't the way forward. It does seem like the right place for whatever solution is adopted.

Configurability is probably good. Perhaps introduce a configurable exception handling strategy implementation executed here. This design would make it easier for you to manage patches from my local fork.

> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>         Attachments: james-imap-client-unstable.patch, james-imap-runtime-catch.patch
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: [jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by Joachim Draeger <jd...@gmx.de>.
Am Montag, den 20.11.2006, 12:48 +0100 schrieb Stefano Bagnara:

> > I hope we'll be able to wipe out the most annoying RuntimeExceptions soon. 
> > IMO catching RuntimeException would lead to undefined behavior and would make reporting bugs more diffuse. 
> > At the moment I don't see a problems with merging, if there are only a few lines to catch exceptions.

> Maybe after having applied JAMES-710 something changed in this regard 
> because the default behaviour of AbstractJamesHandler is to catch 
> RuntimeException.

Isn't the RuntimeException just caught in:

AbstractJamesHandler.handleConnection(Socket connection) 

try {
 handleProtocol(); 
} catch (RuntimeException e) {
...
}

The "command-loop" is in handleProtocol(), so the connection would be
reset anyway when there is a RE in a command. Right? :)

Joachim



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: [jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by Stefano Bagnara <ap...@bago.org>.
Joachim Draeger (JIRA) wrote:
>     [ http://issues.apache.org/jira/browse/JAMES-700?page=comments#action_12451160 ] 
>             
> Joachim Draeger commented on JAMES-700:
> ---------------------------------------
> 
> I hope we'll be able to wipe out the most annoying RuntimeExceptions soon. 
> IMO catching RuntimeException would lead to undefined behavior and would make reporting bugs more diffuse. 
> At the moment I don't see a problems with merging, if there are only a few lines to catch exceptions.


Maybe after having applied JAMES-710 something changed in this regard 
because the default behaviour of AbstractJamesHandler is to catch 
RuntimeException.

Maybe Robert will be able to tell us more after few tests.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Commented: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Joachim Draeger (JIRA)" <se...@james.apache.org>.
    [ http://issues.apache.org/jira/browse/JAMES-700?page=comments#action_12451160 ] 
            
Joachim Draeger commented on JAMES-700:
---------------------------------------

I hope we'll be able to wipe out the most annoying RuntimeExceptions soon. 
IMO catching RuntimeException would lead to undefined behavior and would make reporting bugs more diffuse. 
At the moment I don't see a problems with merging, if there are only a few lines to catch exceptions.



> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>         Attachments: james-imap-client-unstable.patch, james-imap-runtime-catch.patch
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Closed: (IMAP-14) James resets connection when command throws RuntimeException

Posted by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org>.
     [ https://issues.apache.org/jira/browse/IMAP-14?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Burrell Donkin closed IMAP-14.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 0.1

Should be fixed now

> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: IMAP-14
>                 URL: https://issues.apache.org/jira/browse/IMAP-14
>             Project: JAMES Imap
>          Issue Type: Improvement
>            Reporter: Robert Burrell Donkin
>             Fix For: 0.1
>
>         Attachments: james-imap-client-unstable.patch, james-imap-runtime-catch.patch
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Updated: (JAMES-700) James resets connection when command throws RuntimeException

Posted by "Robert Burrell Donkin (JIRA)" <se...@james.apache.org>.
     [ http://issues.apache.org/jira/browse/JAMES-700?page=all ]

Robert Burrell Donkin updated JAMES-700:
----------------------------------------

    Attachment: james-imap-client-unstable.patch

Just FYI

this was my first attempt I had at resolving this issue. it didn't work very well. basically it catchs all runtimes at the handler level. i found it better to resolve this at a lower level (see later). this code is still in my local fork.

IMHO the factoring out is an improvement: it improves diagnostics and readability but the semantics are incorrect (for the reasons you outlined above). 

> James resets connection when command throws RuntimeException
> ------------------------------------------------------------
>
>                 Key: JAMES-700
>                 URL: http://issues.apache.org/jira/browse/JAMES-700
>             Project: James
>          Issue Type: Improvement
>          Components: IMAPServer
>            Reporter: Robert Burrell Donkin
>             Fix For: Trunk
>
>         Attachments: james-imap-client-unstable.patch
>
>
> I think that whenever a exception is thrown when processing an IMAP command the socket connection is reset. This behaviour seems little less polite than it needs to be. IMAP is stateless and IMHO errors should be returned within the band. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org