IMAP: detect and ignore missing message to avoid NullPointerException

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1982 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-07-30 19:37:20 +00:00
parent b4498179b1
commit 939115a471
3 changed files with 9 additions and 0 deletions

View File

@ -704,6 +704,8 @@ public abstract class EWSMethod extends PostMethod {
public int getStatusCode() {
if ("ErrorAccessDenied".equals(errorDetail)) {
return HttpStatus.SC_FORBIDDEN;
} else if ("ErrorItemNotFound".equals(errorDetail)) {
return HttpStatus.SC_NOT_FOUND;
} else {
return super.getStatusCode();
}

View File

@ -540,6 +540,9 @@ public class EwsExchangeSession extends ExchangeSession {
} catch (EWSException e) {
LOGGER.warn("GetItem with MimeContent failed: " + e.getMessage());
}
if (getItemMethod.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
throw new HttpNotFoundException("Item "+itemId+" not found");
}
if (mimeContent == null) {
LOGGER.warn("MimeContent not available, trying to rebuild from properties");
try {

View File

@ -299,6 +299,8 @@ public class ImapConnection extends AbstractConnection {
ExchangeSession.Message message = uidRangeIterator.next();
try {
handleFetch(message, uidRangeIterator.currentIndex, parameters);
} catch (HttpNotFoundException e) {
LOGGER.warn("Ignore missing message "+uidRangeIterator.currentIndex);
} catch (SocketException e) {
// client closed connection
throw e;
@ -383,6 +385,8 @@ public class ImapConnection extends AbstractConnection {
ExchangeSession.Message message = rangeIterator.next();
try {
handleFetch(message, rangeIterator.currentIndex, parameters);
} catch (HttpNotFoundException e) {
LOGGER.warn("Ignore missing message "+rangeIterator.currentIndex);
} catch (SocketException e) {
// client closed connection, rethrow exception
throw e;