You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/03/12 23:28:56 UTC
svn commit: r517430 - in
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http:
HttpSessionStore.java WebSession.java
Author: ehillenius
Date: Mon Mar 12 15:28:53 2007
New Revision: 517430
URL: http://svn.apache.org/viewvc?view=rev&rev=517430
Log:
extra check before writing to the http session.
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/WebSession.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java?view=diff&rev=517430&r1=517429&r2=517430
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java Mon Mar 12 15:28:53 2007
@@ -44,6 +44,7 @@
return new AccessStackPageMap(name, session);
}
+
/**
* @see wicket.session.ISessionStore#getAttribute(wicket.Request,
* java.lang.String)
@@ -88,6 +89,12 @@
*/
public void removeAttribute(Request request, String name)
{
+ // ignore call if the session was marked invalid
+ if (!isSessionValid())
+ {
+ return;
+ }
+
WebRequest webRequest = toWebRequest(request);
HttpSession httpSession = getHttpSession(webRequest);
if (httpSession != null)
@@ -112,6 +119,12 @@
*/
public void setAttribute(Request request, String name, Object value)
{
+ // ignore call if the session was marked invalid
+ if (!isSessionValid())
+ {
+ return;
+ }
+
WebRequest webRequest = toWebRequest(request);
HttpSession httpSession = getHttpSession(webRequest);
if (httpSession != null)
@@ -146,5 +159,23 @@
private String getSessionAttributePrefix(final WebRequest request)
{
return application.getSessionAttributePrefix(request);
+ }
+
+ /**
+ * @return Whether the session was marked invalid during this request
+ * (afterwards, we shouldn't even come here as there is no session)
+ */
+ private boolean isSessionValid()
+ {
+ if (Session.exists())
+ {
+ Session session = Session.get();
+ if (session instanceof WebSession)
+ {
+ return !((WebSession)session).isSessionInvalidated();
+ }
+ }
+ return true; // we simply don't know, so play safe and rely on
+ // servlet container's code to check availability
}
}
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/WebSession.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/WebSession.java?view=diff&rev=517430&r1=517429&r2=517430
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/WebSession.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/WebSession.java Mon Mar 12 15:28:53 2007
@@ -96,7 +96,22 @@
*/
public void invalidateNow()
{
+ sessionInvalidated = true; // set this for isSessionInvalidated
getSessionStore().invalidate(RequestCycle.get().getRequest());
+ }
+
+ /**
+ * Whether the session is invalid now, or will be invalidated by the end of
+ * the request. Clients should rarely need to use this method if ever.
+ *
+ * @return Whether the session is invalid when the current request is done
+ *
+ * @see #invalidate()
+ * @see #invalidateNow()
+ */
+ public final boolean isSessionInvalidated()
+ {
+ return sessionInvalidated;
}
/**