angus-mail icon indicating copy to clipboard operation
angus-mail copied to clipboard

ConnectionListener's closed not invoked when connection is lost

Open mnlipp opened this issue 2 years ago • 0 comments

When the IMAP server closes a connection while the IdleManager is waiting (watching), the ConnectionListener's closed is not invoked.

Here's a stack trace from this condition:

DEBUG IMAP: IdleManager got exception for folder: imap://xxxxxxxx/INBOX, THROW: 
jakarta.mail.FolderClosedException: * BYE Jakarta Mail Exception: java.net.SocketException: Connection reset
	at org.eclipse.angus.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3309)
	at org.eclipse.angus.mail.imap.IdleManager.processKeys(IdleManager.java:351)
	at org.eclipse.angus.mail.imap.IdleManager.select(IdleManager.java:262)
	at org.eclipse.angus.mail.imap.IdleManager.access$200(IdleManager.java:111)
	at org.eclipse.angus.mail.imap.IdleManager$1.run(IdleManager.java:140)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Going through the code, there's nothing that invokes the listeners.

To Reproduce Steps to reproduce the behavior:

  1. Setup IMAP server that closes connections after some idle time
  2. Open folder
  3. Add ConnectionListener to the folder
  4. IdleManager.watch folder

Expected behavior The closed method of all ConnectionListeners added to the folder should be invoked.

mnlipp avatar May 05 '23 15:05 mnlipp