Author: jcompagner
Date: Tue Nov 20 03:10:58 2007
New Revision: 596618
URL: http://svn.apache.org/viewvc?rev=596618&view=rev
Log:
test for null request cycle in bind()
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java?rev=596618&r1=596617&r2=596618&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
(original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
Tue Nov 20 03:10:58 2007
@@ -149,7 +149,7 @@
/** meta data key for missing body tags logging. */
public static final MetaDataKey PAGEMAP_ACCESS_MDK = new MetaDataKey(
- PageMapAccessMetaData.class)
+ PageMapAccessMetaData.class)
{
private static final long serialVersionUID = 1L;
};
@@ -201,7 +201,7 @@
if (requestCycle == null)
{
throw new IllegalStateException(
- "you can only locate or create sessions
in the context of a request cycle");
+ "you can only locate or create sessions in the
context of a request cycle");
}
Response response = requestCycle.getResponse();
Request request = requestCycle.getRequest();
@@ -211,7 +211,7 @@
/**
* @param response
* @param request
- * @return
+ * @return The Session that is found in the current request or created
if not.
*/
public static Session findOrCreate(Request request, Response response)
{
@@ -388,6 +388,11 @@
*/
public final void bind()
{
+ // If there is no request cycle then this is not a normal
request but for example a last
+ // modified call.
+ if (RequestCycle.get() == null)
+ return;
+
ISessionStore store = getSessionStore();
Request request = RequestCycle.get().getRequest();
if (store.lookup(request) == null)
@@ -462,20 +467,20 @@
public synchronized final String createAutoPageMapName()
{
String name = getAutoPageMapNamePrefix() +
currentCreateAutoPageMapCounter() +
- getAutoPageMapNameSuffix();
+ getAutoPageMapNameSuffix();
IPageMap pm = pageMapForName(name, false);
while (pm != null)
{
incrementCreateAutoPageMapCounter();
name = getAutoPageMapNamePrefix() +
currentCreateAutoPageMapCounter() +
- getAutoPageMapNameSuffix();
+ getAutoPageMapNameSuffix();
pm = pageMapForName(name, false);
}
return name;
}
/**
- * @return
+ * @return The prefixed string default "wicket-".
*/
protected String getAutoPageMapNamePrefix()
{
@@ -483,7 +488,7 @@
}
/**
- * @return
+ * @return The suffix default an empty string.
*/
protected String getAutoPageMapNameSuffix()
{
@@ -628,14 +633,14 @@
*
* @param pageId
* @param versionNumber
- * @return
+ * @return The page of that pageid and version, null if not found
*/
public final Page getPage(final int pageId, final int versionNumber)
{
if
(Application.get().getSessionSettings().isPageIdUniquePerSession() == false)
{
throw new IllegalStateException(
- "To call this method
ISessionSettings.setPageIdUniquePerSession must be set to true");
+ "To call this method
ISessionSettings.setPageIdUniquePerSession must be set to true");
}
List pageMaps = getPageMaps();
@@ -694,8 +699,7 @@
// later
Duration timeout =
Application.get().getRequestCycleSettings().getTimeout();
- PageMapsUsedInRequestEntry entry =
(PageMapsUsedInRequestEntry)pageMapsUsedInRequest
- .get(pageMap);
+ PageMapsUsedInRequestEntry entry =
(PageMapsUsedInRequestEntry)pageMapsUsedInRequest.get(pageMap);
// Get page entry for id and version
Thread t = entry != null ? entry.thread : null;
@@ -722,14 +726,14 @@
t = entry != null ? entry.thread : null;
if (t != null && t !=
Thread.currentThread() &&
- (startTime +
timeout.getMilliseconds()) < System.currentTimeMillis())
+ (startTime +
timeout.getMilliseconds()) < System.currentTimeMillis())
{
// if it is still not the right
thread..
// This either points to long
running code (a report
// page?) or a deadlock or such
throw new
WicketRuntimeException("After " + timeout + " the Pagemap " +
- pageMapName + "
is still locked by: " + t +
- ", giving up
trying to get the page for path: " + path);
+ pageMapName + " is
still locked by: " + t +
+ ", giving up trying to
get the page for path: " + path);
}
}
@@ -1245,7 +1249,7 @@
if (cycle == null)
{
throw new IllegalStateException(
- "Cannot set the attribute: no
RequestCycle available. If you get this error when using
WicketTester.startPage(Page), make sure to call
WicketTester.createRequestCycle() beforehand.");
+ "Cannot set the attribute: no
RequestCycle available. If you get this error when using
WicketTester.startPage(Page), make sure to call
WicketTester.createRequestCycle() beforehand.");
}
ISessionStore store = getSessionStore();