javamail - was is the effect of store.close() on open folders?
Asked Answered
A

1

6

I am using javamail to make IMAP connections to gmail. Everything is working going fine. I just want to prevent misusing server memory.

My question is: What does happen when I close the store? [store.close();] does it close all open folders? Do you have to close all folders?

There are tremendous speed benefits if I leave a particular folder open.

Aguish answered 14/1, 2011 at 20:28 Comment(0)
F
4

from the Javamail API Documentation

"Close this service and terminate its connection. A close ConnectionEvent is delivered to any ConnectionListeners. Any Messaging components (Folders, Messages, etc.) belonging to this service are invalid after this service is closed. Note that the service is closed even if this method terminates abnormally by throwing a MessagingException. "

So you can leave the folder open but if you try a second time folder.open, you will have an exception, in this must use:

if(!folder.isOpen()){folder.open();}

i hope that help you

Friarbird answered 18/10, 2011 at 13:35 Comment(1)
I used this kind of checking, but sometimes (very though) hit the folder closed exception. Any suggestion?Coycoyle

© 2022 - 2024 — McMap. All rights reserved.