java - javamail store.isconnected() function bug -
i came across strange bug in javamail store isconnected() function. using in android application reconnect store if connection dropped.
if (!store.isconnected()) store.connect(host, username, password);
but, when connection dropped, function returns true first time called, , false second time called. means above code not trigger store.connect if store not connected, code:
if (!store.isconnected()) store.connect(host, username, password); else if (!store.isconnected()) store.connect(host, username, password);
will reconnect store because of second call isconnected() function return false.
i don't know if explained bug enought. know if known behavior or not. maybe, doing wrong. or, maybe there better way reconnect store if disconnected.
thank in advance!
edit:
this code:
logger.warning("start1"); if (!store.isconnected()) { logger.warning("start1 conn"); store.connect(host, username, password); logger.warning("end1 conn"); } logger.warning("end1"); logger.warning("start2"); if (!store.isconnected()) { logger.warning("start2 conn"); store.connect(host, username, password); logger.warning("end2 conn"); } logger.warning("end2");
outputs in javamail debug:
03-29 15:52:13.162: w/showmailbox(2063): start1 03-29 15:52:15.238: i/system.out(2063): imap debug: imapprotocol noop 03-29 15:52:15.238: i/system.out(2063): a57 noop 03-29 15:52:15.242: i/system.out(2063): debug: imapstore connection dead 03-29 15:52:15.242: i/system.out(2063): debug: imapstore cleanup, force true 03-29 15:52:15.242: i/system.out(2063): debug: imapstore cleanup done 03-29 15:52:22.810: w/showmailbox(2063): end1 03-29 15:52:24.762: w/showmailbox(2063): start2 03-29 15:52:34.033: w/showmailbox(2063): start2 conn 03-29 15:52:36.369: i/system.out(2063): * ok [capability imap4rev1 uidplus children namespace thread=orderedsubject thread=references sort quota idle starttls] courier-imap ready. copyright 1998-2008 double precision, inc. see copying distribution information. 03-29 15:52:36.369: i/system.out(2063): a0 capability ... 03-29 15:52:37.857: i/system.out(2063): a3 ok login ok. 03-29 15:52:38.053: i/system.out(2063): imap debug: auth: plain 03-29 15:52:39.297: w/showmailbox(2063): end2 conn 03-29 15:52:40.885: w/showmailbox(2063): end2
it looks first call isconnected() executed returning true if store not connected , second isconnected() not executed @ all!? executes connect() function!?
i confused. , little scared... :)
you're running bug fixed in javamail 1.4.2. should able use newest version of javamail along additionnal.jar , activation.jar files.
Comments
Post a Comment