summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-01-14 17:25:42 +0200
committerHenri Sara <hesara@vaadin.com>2013-01-14 17:25:42 +0200
commit13261dc275d1cda7ef5436d6bc6ff649c1338cb6 (patch)
tree249212c89528cc6cd2502adfa26817563ae29d32 /server
parentcbe5abeb4c8221a56e116f445a6f054881eb6ce4 (diff)
downloadvaadin-framework-13261dc275d1cda7ef5436d6bc6ff649c1338cb6.tar.gz
vaadin-framework-13261dc275d1cda7ef5436d6bc6ff649c1338cb6.zip
Use default session expiration on GAE if undefined (#10434)
Change-Id: Icb38dbc05ecfefb1dd5710b53f1e5fab76a3ed09
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/GAEVaadinServlet.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java
index aef8a7a5c5..140ed54828 100644
--- a/server/src/com/vaadin/server/GAEVaadinServlet.java
+++ b/server/src/com/vaadin/server/GAEVaadinServlet.java
@@ -132,6 +132,10 @@ public class GAEVaadinServlet extends VaadinServlet {
// appengine session expires-parameter
private static final String PROPERTY_APPENGINE_EXPIRES = "_expires";
+ // sessions with undefined (-1) expiration are limited to this, but explicit
+ // longer timeouts can be used
+ private static final int DEFAULT_MAX_INACTIVE_INTERVAL = 24 * 3600;
+
protected void sendDeadlineExceededNotification(
VaadinServletRequest request, VaadinServletResponse response)
throws IOException {
@@ -256,7 +260,7 @@ public class GAEVaadinServlet extends VaadinServlet {
String id = AC_BASE + session.getId();
Date expire = new Date(started
- + (session.getMaxInactiveInterval() * 1000));
+ + (getMaxInactiveIntervalSeconds(session) * 1000));
Expiration expires = Expiration.onDate(expire);
memcache.put(id, bytes, expires);
@@ -290,6 +294,24 @@ public class GAEVaadinServlet extends VaadinServlet {
}
}
+ /**
+ * Returns the maximum inactive time for a session. This is used for
+ * handling the expiration of session related information in caches etc.
+ *
+ * @param session
+ * @return inactive timeout in seconds, greater than zero
+ */
+ protected int getMaxInactiveIntervalSeconds(final HttpSession session) {
+ int interval = session.getMaxInactiveInterval();
+ if (interval <= 0) {
+ getLogger()
+ .log(Level.FINE,
+ "Undefined session expiration time, using default value instead.");
+ return DEFAULT_MAX_INACTIVE_INTERVAL;
+ }
+ return interval;
+ }
+
protected VaadinSession getApplicationContext(HttpServletRequest request,
MemcacheService memcache) throws ServletException {
HttpSession session = request.getSession();
@@ -308,9 +330,11 @@ public class GAEVaadinServlet extends VaadinServlet {
Blob blob = (Blob) entity.getProperty(PROPERTY_DATA);
serializedAC = blob.getBytes();
// bring it to memcache
- memcache.put(AC_BASE + session.getId(), serializedAC,
- Expiration.byDeltaSeconds(session
- .getMaxInactiveInterval()),
+ memcache.put(
+ AC_BASE + session.getId(),
+ serializedAC,
+ Expiration
+ .byDeltaSeconds(getMaxInactiveIntervalSeconds(session)),
MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT);
}
}