mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
Improve socket closed error handling
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1374 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
70f0cf851e
commit
3ecc0aa80e
@ -1534,6 +1534,7 @@ public abstract class ExchangeSession {
|
|||||||
// load and parse message
|
// load and parse message
|
||||||
mimeBody = new SharedByteArrayInputStream(getContent(this));
|
mimeBody = new SharedByteArrayInputStream(getContent(this));
|
||||||
mimeMessage = new MimeMessage(null, mimeBody);
|
mimeMessage = new MimeMessage(null, mimeBody);
|
||||||
|
mimeBody.reset();
|
||||||
LOGGER.debug("Downloaded full message content for IMAP UID " + imapUid + " (" + mimeBody.available() + " bytes)");
|
LOGGER.debug("Downloaded full message content for IMAP UID " + imapUid + " (" + mimeBody.available() + " bytes)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import davmail.ui.tray.DavGatewayTray;
|
|||||||
import davmail.util.IOUtil;
|
import davmail.util.IOUtil;
|
||||||
import davmail.util.StringUtil;
|
import davmail.util.StringUtil;
|
||||||
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.HttpException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.*;
|
import javax.mail.internet.*;
|
||||||
@ -49,6 +50,7 @@ import java.util.*;
|
|||||||
* Still alpha code : need to find a way to handle message ids
|
* Still alpha code : need to find a way to handle message ids
|
||||||
*/
|
*/
|
||||||
public class ImapConnection extends AbstractConnection {
|
public class ImapConnection extends AbstractConnection {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(ImapConnection.class);
|
||||||
|
|
||||||
ExchangeSession.Folder currentFolder;
|
ExchangeSession.Folder currentFolder;
|
||||||
|
|
||||||
@ -278,6 +280,9 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
ExchangeSession.Message message = uidRangeIterator.next();
|
ExchangeSession.Message message = uidRangeIterator.next();
|
||||||
try {
|
try {
|
||||||
handleFetch(message, uidRangeIterator.currentIndex, parameters);
|
handleFetch(message, uidRangeIterator.currentIndex, parameters);
|
||||||
|
} catch (SocketException e) {
|
||||||
|
// client closed connection
|
||||||
|
throw e;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
DavGatewayTray.log(e);
|
DavGatewayTray.log(e);
|
||||||
sendClient(commandId + " NO Unable to retrieve message: " + e.getMessage());
|
sendClient(commandId + " NO Unable to retrieve message: " + e.getMessage());
|
||||||
@ -549,7 +554,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
DavGatewayTray.debug(new BundleMessage("LOG_EXCEPTION_CLOSING_CONNECTION_ON_TIMEOUT"));
|
DavGatewayTray.debug(new BundleMessage("LOG_EXCEPTION_CLOSING_CONNECTION_ON_TIMEOUT"));
|
||||||
}
|
}
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"));
|
LOGGER.warn(BundleMessage.formatLog("LOG_CLIENT_CLOSED_CONNECTION"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DavGatewayTray.log(e);
|
DavGatewayTray.log(e);
|
||||||
try {
|
try {
|
||||||
|
@ -27,7 +27,9 @@ import davmail.Settings;
|
|||||||
import davmail.exception.DavMailException;
|
import davmail.exception.DavMailException;
|
||||||
import davmail.exchange.ExchangeSession;
|
import davmail.exchange.ExchangeSession;
|
||||||
import davmail.exchange.ExchangeSessionFactory;
|
import davmail.exchange.ExchangeSessionFactory;
|
||||||
|
import davmail.imap.ImapConnection;
|
||||||
import davmail.ui.tray.DavGatewayTray;
|
import davmail.ui.tray.DavGatewayTray;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
@ -43,6 +45,7 @@ import java.util.*;
|
|||||||
* Handle a caldav connection.
|
* Handle a caldav connection.
|
||||||
*/
|
*/
|
||||||
public class LdapConnection extends AbstractConnection {
|
public class LdapConnection extends AbstractConnection {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(LdapConnection.class);
|
||||||
/**
|
/**
|
||||||
* Davmail base context
|
* Davmail base context
|
||||||
*/
|
*/
|
||||||
@ -1390,7 +1393,7 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
// client closed connection
|
// client closed connection
|
||||||
DavGatewayTray.debug(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"));
|
LOGGER.warn(BundleMessage.formatLog("LOG_CLIENT_CLOSED_CONNECTION"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
DavGatewayTray.log(e);
|
DavGatewayTray.log(e);
|
||||||
try {
|
try {
|
||||||
|
@ -25,6 +25,7 @@ import davmail.exchange.ExchangeSession;
|
|||||||
import davmail.exchange.ExchangeSessionFactory;
|
import davmail.exchange.ExchangeSessionFactory;
|
||||||
import davmail.ui.tray.DavGatewayTray;
|
import davmail.ui.tray.DavGatewayTray;
|
||||||
import davmail.util.IOUtil;
|
import davmail.util.IOUtil;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.FilterOutputStream;
|
import java.io.FilterOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -39,6 +40,8 @@ import java.util.StringTokenizer;
|
|||||||
* Dav Gateway pop connection implementation
|
* Dav Gateway pop connection implementation
|
||||||
*/
|
*/
|
||||||
public class PopConnection extends AbstractConnection {
|
public class PopConnection extends AbstractConnection {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(PopConnection.class);
|
||||||
|
|
||||||
private List<ExchangeSession.Message> messages;
|
private List<ExchangeSession.Message> messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,7 +139,7 @@ public class PopConnection extends AbstractConnection {
|
|||||||
state = State.AUTHENTICATED;
|
state = State.AUTHENTICATED;
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
// can not send error to client after a socket exception
|
// can not send error to client after a socket exception
|
||||||
DavGatewayTray.warn(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"), e);
|
LOGGER.warn(BundleMessage.formatLog("LOG_CLIENT_CLOSED_CONNECTION"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DavGatewayTray.error(e);
|
DavGatewayTray.error(e);
|
||||||
sendERR(e);
|
sendERR(e);
|
||||||
@ -202,7 +205,7 @@ public class PopConnection extends AbstractConnection {
|
|||||||
doubleDotOutputStream.close();
|
doubleDotOutputStream.close();
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
// can not send error to client after a socket exception
|
// can not send error to client after a socket exception
|
||||||
DavGatewayTray.warn(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"), e);
|
LOGGER.warn(BundleMessage.formatLog("LOG_CLIENT_CLOSED_CONNECTION"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DavGatewayTray.error(new BundleMessage("LOG_ERROR_RETRIEVING_MESSAGE"), e);
|
DavGatewayTray.error(new BundleMessage("LOG_ERROR_RETRIEVING_MESSAGE"), e);
|
||||||
sendERR("error retreiving message " + e + ' ' + e.getMessage());
|
sendERR("error retreiving message " + e + ' ' + e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user