eclipse-ee4j / eclipse-ee4j/angus-mail

ConnectionListener's closed not invoked when connection is lost

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
87
Forks
23
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.