amu123 / javamail-android

Automatically exported from code.google.com/p/javamail-android
0 stars 0 forks source link

Deadlock Issuing IMAP Command while Idle running. #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Thread 1 is running and blocked in the IMAPFolder.idle method.
2.The underlying connection is some how broken but the idle command 
doesn't know it so no exception is thrown.
3.Thread 2 calls into IMAPFolder.isOpen (1149) method, which takes the 
IMAPFolder lock and then the messageCacheLock and calls 
IMAPFolder.keepConnectionAlive (2671).  That calls IMAPFolder.waitIfIdle 
(2276) which detects it is idling, calls idleAbort and then calls wait on 
the messageCacheLock.  But it still holds the IMAPFolder lock.
4. Now Thread 1 gets the abort and throws an ConnectionException and calls 
IMAPFolder.throwClosedException (2449) which requires the IMAPFolder lock, 
but it can't have it because Thread 2 has it, and now we are deadlocked.

What is the expected output? What do you see instead?
Not a deadlock

What version of the product are you using? On what operating system?
Not sure, Jar doesn't have a version in it but it was the latest as of 2 
weeks ago when I downloaded.

Please provide any additional information below.
I think either the throwClosedException shouldn't take the lock or there 
should be a flag introduced to show that we are ending the idle on purpose 
and hence we don't really care about the idle exception.

Original issue reported on code.google.com by j...@ahg.net on 10 Feb 2010 at 9:21

GoogleCodeExporter commented 9 years ago
So I now see your comment on the homepage about no bug reports.  That's cool, I 
was 
actually about to do my own patch anyway.  But now i have a question on 
building the 
mail.jar, I see maven and ant scripts in there, not sure what I should use.  
The ant 
scripts seem to depened on stuff from glassfish, so I just want to do my build 
and 
testing with the same setup you have going.

Thanks.

Original comment by j...@ahg.net on 24 Mar 2010 at 2:38