oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 723 forks source link

envelopeOnly() results in lots of fetching compared to folder.search #767

Closed maxandersen closed 4 years ago

maxandersen commented 4 years ago

Current behavior

when doing:

var mails = session.receive().filter( EmailFilter.filter().flag(Flag.SEEN, false)) .envelopeOnly() .get();

the amount of data fetched is much larger than when doing:

f.open(javax.mail.Folder.READ_ONLY);

var messages = f.search(EmailFilter.filter().flag(Flag.SEEN, false).getSearchTerm());

Expected behavior

there should be a way to fetch just the minimum data to make initial searches faster.

...i'm wondering if jodd email assumes you will always be interested in all data ?

igr commented 4 years ago

Speaking out loud w/o looking at the code, Jodd email should not perform any additional logic to underlying mail library. I will check whats going on.

How did you measure the amount of data?

igr commented 4 years ago

As said, Jodd is just passing the flag to the implementation:

https://github.com/oblac/jodd/blob/723bba35881d0f9fb9b2c28821dcded976ae70ab/jodd-mail/src/main/java/jodd/mail/ReceiverBuilder.java#L121