commits@javamail.java.net

[mercurial:136] Fix deadlock in IMAP IDLE support.

From: <shannon_at_kenai.com>
Date: Fri, 8 May 2009 20:35:39 +0000 (GMT)

Repository: mercurial
Revision: 136
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2009-05-06 22:54:27 UTC
Link:
http://kenai.com/projects/javamail/sources/mercurial/revision/136

Log Message:
-----------
Fix deadlock in IMAP IDLE support.

Modified Paths:
--------------
    doc/release/CHANGES.txt
    mail/src/main/java/com/sun/mail/imap/IMAPFolder.java

Diffs:
-----
diff -r cb590f44fcb4 -r 9b5751010a75 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Thu Apr 16 15:52:07 2009 -0700
+++ b/doc/release/CHANGES.txt Wed May 06 15:54:27 2009 -0700
@@ -14,6 +14,7 @@
 The following bugs have been fixed in the 1.4.3 release.
 
 <no id> add starttls support to POP3
+<no id> fix deadlock in IMAP IDLE support
 
 
                  CHANGES IN THE 1.4.2 RELEASE
diff -r cb590f44fcb4 -r 9b5751010a75
mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Thu Apr
16 15:52:07 2009 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Wed May
06 15:54:27 2009 -0700
@@ -2237,11 +2237,17 @@
            Response r = protocol.readIdleResponse();
            try {
                synchronized (messageCacheLock) {
- if (r == null || protocol == null ||
- !protocol.processIdleResponse(r)) {
+ try {
+ if (r == null || protocol == null ||
+ !protocol.processIdleResponse(r)) {
+ idleState = RUNNING;
+ messageCacheLock.notifyAll();
+ break;
+ }
+ } catch (ProtocolException pex) {
                        idleState = RUNNING;
                        messageCacheLock.notifyAll();
- break;
+ throw pex;
                    }
                }
            } catch (ConnectionException cex) {