vshardul / java-gmail-imap

Automatically exported from code.google.com/p/java-gmail-imap
0 stars 0 forks source link

Possible issue/concern regarding the fetching of x-gm-labels #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello Mark,

While I was coding for my project, using java-gmail-imap, I came across an 
issue which, in my opinion, is important.

The issue can be easily reproduced as I explain below:

1. Fetch x-gm-labels for an email.
2. Change this email's labels using some other client (the gmail web client is, 
of course, the obvious way)
3. Re-fetch x-gm-labels for the email.
4. No changes appear to have happened to the email's labels.

I traced this error and I discovered that actually no FETCH command is sent to 
the gmail server in step 3.
This happens because FetchProfileCondition.test(IMAPMessage m) called from 
Utility.toMessageSet() during the execution of IMAPMessage.fetch returns false.

This actually happens because the condition in the 'if' below...

1035    if (needXGmLabels && m.getGoogleMessageLabels() == null)
1036         return true;

... is always false for any message in the messageCache for which we have 
already fetched x-gm-labels. 

A simple solution is to remove the m.getGoogleMessageLabels() == null 
condition. By doing this, everything works fine. 

My opinion is that because x-gm-labels is an attribute that COULD change by 
another client during a session (unlike headers, envelope, size, UID, 
x-gm-msgid etc.) the m.getGoogleMessageLabels() == null condition should be 
removed.

I'm looking forward to hearing your opinion on this.

Best wishes,
Stefanos

Original issue reported on code.google.com by stange...@gmail.com on 26 Nov 2011 at 7:36