You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2011/03/04 11:00:28 UTC

svn commit: r1077860 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java

Author: mgrigorov
Date: Fri Mar  4 10:00:24 2011
New Revision: 1077860

URL: http://svn.apache.org/viewvc?rev=1077860&view=rev
Log:
WICKET-3498 Entering huge strings in TextFields causes IllegalStateExceptions not caught by the Framework

try/catch the read of wicket-ajax header and response so that it is possible to create Wicket Request object.
At this point it is not possible to redirect to Wicket's error pages.
Just log the error and assume it is non-Ajax request. Later if the same error occurs while reading header or parameter it will be possible to restart the request cycle and redirect to more specific error page.


Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java?rev=1077860&r1=1077859&r2=1077860&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java Fri Mar  4 10:00:24 2011
@@ -77,23 +77,36 @@ public class ServletWebRequest extends W
 		this.httpServletRequest = httpServletRequest;
 
 		ajax = false;
-		String ajaxHeader = httpServletRequest.getHeader("Wicket-Ajax");
 
-		if (Strings.isEmpty(ajaxHeader))
-			ajaxHeader = httpServletRequest.getParameter("wicket:ajax");
-
-		if (Strings.isEmpty(ajaxHeader) == false)
+		try
 		{
-			try
+			String ajaxHeader = httpServletRequest.getHeader("Wicket-Ajax");
+
+			if (Strings.isEmpty(ajaxHeader))
 			{
-				ajax = Strings.isTrue(ajaxHeader);
+				ajaxHeader = httpServletRequest.getParameter("wicket:ajax");
 			}
-			catch (StringValueConversionException e)
+
+			if (Strings.isEmpty(ajaxHeader) == false)
 			{
-				// We are not interested in this exception but we log it anyway
-				log.debug("Couldn't convert the Wicket-Ajax header: " + ajaxHeader);
+				try
+				{
+					ajax = Strings.isTrue(ajaxHeader);
+				}
+				catch (StringValueConversionException e)
+				{
+					// We are not interested in this exception but we log it anyway
+					log.debug("Couldn't convert the Wicket-Ajax header: " + ajaxHeader);
+				}
 			}
 		}
+		catch (IllegalStateException isx)
+		{
+			// Log the exception and assume this is non-ajax request.
+			// Later if an error occurs again while reading headers/parameters
+			// it will be possible to redirect to the configured error pages
+			log.error("A problem occurred while reading 'wicket:ajax' header/parameter.", isx);
+		}
 	}
 
 	/**