Skip to content

Commit 2a6ab85

Browse files
Merge pull request #123 from k-r-g/sessionInvalidateFix
When invalidating the session make it possible to start using a new one
2 parents 5c593f9 + 288d0e3 commit 2a6ab85

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

gemini/src/main/java/com/techempower/gemini/Context.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,20 @@ public Session getSession(boolean create)
386386
return this.session;
387387
}
388388

389+
/**
390+
* In addition to invalidating the session, also sets the Context.session member variable to null
391+
* so it is re-created as needed and is available for immediate use.
392+
*/
393+
public void invalidateSession()
394+
{
395+
if (this.session != null)
396+
{
397+
this.session.invalidate();
398+
}
399+
// Rely on getSession() to create a new session as needed.
400+
this.session = null;
401+
}
402+
389403
/**
390404
* Gets the full standard (non-secure) URL to the Servlet.
391405
*/

gemini/src/main/java/com/techempower/gemini/context/SessionNamedValues.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,7 @@ public SessionNamedValues clear()
306306
*/
307307
public SessionNamedValues invalidate()
308308
{
309-
final Session session = context.getSession(false);
310-
if (session != null)
311-
{
312-
session.invalidate();
313-
}
309+
context.invalidateSession();
314310
return this;
315311
}
316312

0 commit comments

Comments
 (0)