Folder objects sharing same folder

"foo" <[email protected]> Wed, 22 Aug 2007 15:18:43 -0700
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
I am trying to append messages to an IMAP folder. My IMAP server, for some 
reason, does not allow appending messages to a folder that is opened 
read-only

If I do the following code:

Folder f = store.getFolder("foo");
f.appendMessages(msgs);

It succeeds, because you can append messages to a closed folder.

If I do the following code:

Folder f = store.getFolder("foo");
f.open(Folder.READ_ONLY);
f.appendMessages(msgs);

It fails, because you cannot append messages to a folder opened read-only.

But if I create another Folder object which points to the same folder 
without opening it, it still fails:

Folder f = store.getFolder("foo");
f.open(Folder.READ_ONLY);
Folder g = store.getFolder("foo");
g.appendMessages(msgs);

Even though the Folder object "g" has not been "opened". Is this because 
they both share the same connection or something? How do I work around this?

Thanks,