IMAPFolder type issue

Neil Campbell <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
Hi everyone,

I've been playing around with the ClasspathX JavaMail implementation and using 
it with my application as a replacement for the Sun version.

So far I'm very impressed, although I have spotted a possible issue with the 
IMAPFolder.

In IMAPFolder.getType(), as well as in IMAPFolder.getFolders(), the type is 
assigned to be either HOLDS_MESSAGES or HOLDS_FOLDERS.  However, I note that 
the Sun implementation differs, in that a folder can hold both messages and 
folders.

I'm not familiar enough with the IMAP protocol to know which is correct, but I 
think your implementation can be made to behave the same way as Sun's in this 
case by changing:

type = entries[0].isNoinferiors() ?
    Folder.HOLDS_MESSAGES :
    Folder.HOLDS_FOLDERS;

to something along the lines of

type = 0;

if(!entries[0].isNoinferiors()) {
 type |= Folder.HOLDS_FOLDERS;
}
if(!entries[0].isNoselect()) {
 type |= Folder.HOLDS_MESSAGES;
}

in both cases.  Similarly, I suppose that in create(int type) the line:
if (type == HOLDS_FOLDERS)

should be:
if ((type & HOLDS_FOLDERS) != 0)

Does this seem reasonable?

Cheers,
Neil
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.