jakartaee / jakartaee/mail-api
javamail cannot issue UID FETCH and doesn't fully support workaround
- Dominant language
- Java
- Stars
- 285
- Forks
- 109
- Avg merge
- 15h 19m
- Merged PRs (30d)
- 1
Description
Javamail doesn't support UID FETCH at present. You *can* get a Message by UID and then do a FETCH by sequence number, but that's an extra round trip.
The semi-obvious workaround for this is to use Folder.doCommand() and issue a UID FETCH of your own:
folder.doCommand(p -> {
p.simpleCommand("UID FETCH", args);
return null;
});
And this works... mostly. If there's a message with that UID in the folder, the IMAP server will return an untagged FETCH response which will be caught by Protocol.simpleCommand() and handed off to Protocol.notifyResponseHandlers() and then to IMAPFolder.handleResponse(). It finally lands in IMAPFolder.processFetchResponse(), which handles UID, MODSEQ, FLAGS, and extensions. Everything else is dropped. (IMAPFolder.handleResponse also sends a MessageChangedEvent, which is not optimal, but it's not an issue for me as I don't have any listeners active on the Folder.)
Would it be possible to either
a) support UID FETCH directly, or
b) have IMAPFolder.processFetchResponse() handle at least a larger subset of the other fetch items, like IMAPMessage.handleFetchItem() does?
#### Affected Versions
1.5.5
#### Environment
PC
Mac OS
Contributor guide
Assessment
This issue has not been assessed yet.