diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java index 76d5509a26e..7dc90eaa098 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java @@ -296,17 +296,20 @@ public class JDBCSessionManager extends AbstractSessionManager super.complete(); try { - if (_dirty) + if (isValid()) { - //The session attributes have changed, write to the db, ensuring - //http passivation/activation listeners called - willPassivate(); - updateSession(this); - didActivate(); - } - else if ((getAccessed() - _lastSaved) >= (getSaveInterval() * 1000L)) - { - updateSessionAccessTime(this); + if (_dirty) + { + //The session attributes have changed, write to the db, ensuring + //http passivation/activation listeners called + willPassivate(); + updateSession(this); + didActivate(); + } + else if ((getAccessed() - _lastSaved) >= (getSaveInterval() * 1000L)) + { + updateSessionAccessTime(this); + } } } catch (Exception e)