I've got a code that worked perfectly with mail 1.1.1 but has
problems with 1.1.2.
----------------------------------------------------------------
store.connect();
Folder folder = store.getFolder("a cyrus imap folder");
folder.open(Folder.READ_WRITE);
log.info("Total messages: " + folder.getMessageCount());
Message[] msgs = folder.search(aTerm);
processMessages(msgs);
folder.expunge();
// folder.getMode() still returns Folder.READ_WRITE here
msgs = folder.search(aDifferentTerm);
// folder.getMode() now returns Folder.READ_ONLY!!
processMessages(msgs);
folder.expunge();
----------------------------------------------------------------
The second folder.expunge() throws
javax.mail.MessagingException: Folder was opened read-only
at gnu.mail.providers.imap.IMAPFolder.expunge(IMAPFolder.java:
530)
Using some more log.info() I found out that the Folder.mode is
altered by the second search. I couldn't find anything in the
JavaDocs that this is a regular behaviour. As it worked with the
previous release, you may know what the problem could be.