mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-04 14:52:24 -05:00
IMAP: interrupt EWS folder load on client timeout
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2142 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
7a371723ee
commit
badbdc5bc6
@ -696,6 +696,10 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
executeMethod(findItemMethod);
|
||||
results.addAll(findItemMethod.getResponseItems());
|
||||
offset = results.size();
|
||||
if (Thread.interrupted()) {
|
||||
LOGGER.debug("Search items failed: Interrupted by client");
|
||||
throw new IOException("Search items failed: Interrupted by client");
|
||||
}
|
||||
} while (!(findItemMethod.includesLastItemInRange || (maxCount > 0 && offset == maxCount)));
|
||||
return results;
|
||||
}
|
||||
|
@ -258,8 +258,13 @@ public class ImapConnection extends AbstractConnection {
|
||||
while (!folderLoadThread.isComplete) {
|
||||
folderLoadThread.join(20000);
|
||||
LOGGER.debug("Still loading " + currentFolder.folderPath+" ("+currentFolder.count()+" messages)");
|
||||
os.write(' ');
|
||||
os.flush();
|
||||
try {
|
||||
os.write(' ');
|
||||
os.flush();
|
||||
} catch (SocketException e) {
|
||||
folderLoadThread.interrupt();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
sendClient(" " + currentFolder.count() + " EXISTS");
|
||||
if (folderLoadThread.exception != null) {
|
||||
@ -1972,4 +1977,34 @@ public class ImapConnection extends AbstractConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public void testInvalidHeaders() throws MessagingException {
|
||||
String messageHeaders = "Microsoft Mail Internet Headers Version 2.0\r\n" +
|
||||
"Received: from mail.litwareinc.com ([10.54.108.101]) by mail.proseware.com with Microsoft SMTPSVC(6.0.3790.0);\r\n" +
|
||||
"Wed, 12 Dec 2007 13:39:22 -0800\r\n" +
|
||||
"Received: from mail ([10.54.108.23] RDNS failed) by mail.litware.com with Microsoft SMTPSVC(6.0.3790.0);\r\n" +
|
||||
"Wed, 12 Dec 2007 13:38:49 -0800\r\n" +
|
||||
"From: \"Kelly J. Weadock\" <kelly@litware.com>\n" +
|
||||
"To: <anton@proseware.com>\n" +
|
||||
"Cc: <tim@cpandl.com>\n" +
|
||||
"Subject: Review of staff assignments\n" +
|
||||
"Date: Wed, 12 Dec 2007 13:38:31 -0800\n" +
|
||||
"MIME-Version: 1.0\n" +
|
||||
"Content-Type: multipart/mixed;\n" +
|
||||
"X-Mailer: Microsoft Office Outlook, Build 12.0.4210\n" +
|
||||
"X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165\n" +
|
||||
"Thread-Index: AcON3CInEwkfLOQsQGeK8VCv3M+ipA==\n" +
|
||||
"Return-Path: kelly@litware.com\n" +
|
||||
"Message-ID: <MAILbbnewS5TqCRL00000013@mail.litware.com>\n" +
|
||||
"X-OriginalArrivalTime: 12 Dec 2007 21:38:50.0145 (UTC)";
|
||||
final String MS_HEADER = "Microsoft Mail Internet Headers Version 2.0\r\n";
|
||||
if (messageHeaders.startsWith(MS_HEADER)) {
|
||||
messageHeaders = messageHeaders.substring(MS_HEADER.length());
|
||||
}
|
||||
Enumeration enumeration = new InternetHeaders(new ByteArrayInputStream(messageHeaders.getBytes())).getAllHeaderLines();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
System.out.println(enumeration.nextElement());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user