From 39d21aee0a3fbfb86b43d38573d3a3b812832b39 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 9 Dec 2013 17:16:54 +1100 Subject: [PATCH] 410750 NPE Protection in Mongo save session --- .../jetty/nosql/mongodb/MongoSessionManager.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java index 3782ceda3ed..102a6915bf5 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java @@ -262,12 +262,15 @@ public class MongoSessionManager extends NoSqlSessionManager fields.append(__MAX_IDLE, true); fields.append(__EXPIRY, true); DBObject o = _dbSessions.findOne(new BasicDBObject("id",session.getClusterId()), fields); - Integer currentMaxIdle = (Integer)o.get(__MAX_IDLE); - Long currentExpiry = (Long)o.get(__EXPIRY); - if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle) - sets.put(__MAX_IDLE, getMaxInactiveInterval()); - if (currentExpiry != null && expiry > 0 && expiry < currentExpiry) - sets.put(__EXPIRY, currentExpiry); + if (o != null) + { + Integer currentMaxIdle = (Integer)o.get(__MAX_IDLE); + Long currentExpiry = (Long)o.get(__EXPIRY); + if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle) + sets.put(__MAX_IDLE, getMaxInactiveInterval()); + if (currentExpiry != null && expiry > 0 && expiry < currentExpiry) + sets.put(__EXPIRY, currentExpiry); + } } sets.put(__ACCESSED,session.getAccessed());