linagora / james-project

Mirror of Apache James Project
Apache License 2.0
70 stars 63 forks source link

[FIX] IMAP execution management #5114

Closed chibenwa closed 6 months ago

chibenwa commented 6 months ago

That is my best shot at explaining:

java.lang.NullPointerException: Cannot invoke "org.apache.james.imap.api.process.SelectedMailbox.existsCount()" because "selected" is null

CF https://github.com/linagora/james-project/issues/4688 which was mostly fixed incorrectly...

The Netty stack enforce linearisability of operation conducted on the event loop for a single channel, including command decoding.

For command execution, we trigger the processing only reactor. We rely on a linarizer to enforce sequential IMAP execution.

So in theory we do never execute two IMAP commands of a given connection at the same time.

However no mechanism prevents decoding at the same time than command execution - and that is fine - however the channel operations (inactive, idle, parsing failures) MAY interfere with command execution by deciding a logout eventually deselecting the current mailbox and resulting in the NPE.

Lessons learned: always cancel current command execution before deciding to log out!

That, and we were executing blocking code onto the netty event loop which IS BAD.