From ec6634d043489ac2a2c626165c62b72b1e38d5bb Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 23 Apr 2010 14:59:30 +0000 Subject: [PATCH] IMAP: Handle exception during IDLE git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1021 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/imap/ImapConnection.java | 37 +++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index 4935ce0d..52430605 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -431,24 +431,29 @@ public class ImapConnection extends AbstractConnection { // clear cache before going to idle mode currentFolder.clearCache(); DavGatewayTray.resetIcon(); - int count = 0; - while (!in.ready()) { - if (++count >= imapIdleDelay) { - count = 0; - List previousImapUidList = currentFolder.getImapUidList(); - if (session.refreshFolder(currentFolder)) { - handleRefresh(previousImapUidList, currentFolder.getImapUidList()); + try { + int count = 0; + while (!in.ready()) { + if (++count >= imapIdleDelay) { + count = 0; + List previousImapUidList = currentFolder.getImapUidList(); + if (session.refreshFolder(currentFolder)) { + handleRefresh(previousImapUidList, currentFolder.getImapUidList()); + } } + // sleep 1 second + Thread.sleep(1000); } - // sleep 1 second - Thread.sleep(1000); - } - // read DONE line - line = readClient(); - if ("DONE".equals(line)) { - sendClient(commandId + " OK " + command + " terminated"); - } else { - sendClient(commandId + " BAD command unrecognized"); + // read DONE line + line = readClient(); + if ("DONE".equals(line)) { + sendClient(commandId + " OK " + command + " terminated"); + } else { + sendClient(commandId + " BAD command unrecognized"); + } + } catch (IOException e) { + // client connection closed + throw new SocketException(e.getMessage()); } } else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) { if (currentFolder != null) {