From 1a92e17d07c1225ce14106fb0a12f82a7c3e2e97 Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 13 Apr 2011 21:34:00 +0000 Subject: [PATCH] Dav: experimental, try to reset session timeout with a GET method git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1666 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../exchange/dav/DavExchangeSession.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 2d6c3f1b..fca3cdc8 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -51,6 +51,7 @@ import javax.mail.util.SharedByteArrayInputStream; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import java.io.*; +import java.net.NoRouteToHostException; import java.net.URL; import java.net.UnknownHostException; import java.text.ParseException; @@ -103,6 +104,25 @@ public class DavExchangeSession extends ExchangeSession { protected static final String USERS = "/users/"; + @Override + public boolean isExpired() throws NoRouteToHostException, UnknownHostException { + // experimental: try to reset session timeout + GetMethod getMethod = null; + try { + getMethod = new GetMethod(URIUtil.encodePath(getFolderPath(""))); + httpClient.executeMethod(getMethod); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } finally { + if (getMethod != null) { + getMethod.releaseConnection(); + } + } + + return super.isExpired(); + } + + /** * Convert logical or relative folder path to exchange folder path. *