You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/04/26 18:39:14 UTC
cvs commit: jakarta-tomcat-4.0/tester/src/tester/org/apache/tester ErrorPage04.java ErrorPage06.java
craigmcc 01/04/26 09:39:14
Modified: tester/src/tester/org/apache/tester ErrorPage04.java
ErrorPage06.java
Log:
[PFD2-9.9] Revise the error page propogation tests to reflect the fact that
the actual exception that was thrown is forwarded to the error pages.
Previously, if the actual exception was a ServletException with a rootCause
embedded, the rootCause exception was unwrapped and its information was
forwarded.
Revision Changes Path
1.3 +19 -7 jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage04.java
Index: ErrorPage04.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage04.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ErrorPage04.java 2001/03/18 06:12:55 1.2
+++ ErrorPage04.java 2001/04/26 16:39:13 1.3
@@ -67,7 +67,7 @@
* the ErrorPage01 servlet returns the appropriate exception.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2001/03/18 06:12:55 $
+ * @version $Revision: 1.3 $ $Date: 2001/04/26 16:39:13 $
*/
public class ErrorPage04 extends HttpServlet {
@@ -81,22 +81,34 @@
PrintWriter writer = response.getWriter();
// Accumulate all the reasons this request might fail
+ ServletException exception = null;
+ Throwable rootCause = null;
StringBuffer sb = new StringBuffer();
Object value = null;
value = request.getAttribute("javax.servlet.error.exception");
if (value == null)
sb.append(" exception is missing/");
- else if (!(value instanceof TesterException)) {
+ else if (!(value instanceof javax.servlet.ServletException)) {
sb.append(" exception class is ");
sb.append(value.getClass().getName());
sb.append("/");
} else {
- TesterException te = (TesterException) value;
- if (!"ErrorPage03 Threw Exception".equals(te.getMessage())) {
- sb.append(" exception message is ");
- sb.append(te.getMessage());
+ exception = (ServletException) value;
+ rootCause = exception.getRootCause();
+ if (rootCause == null) {
+ sb.append(" rootCause is missing/");
+ } else if (!(rootCause instanceof TesterException)) {
+ sb.append(" rootCause is ");
+ sb.append(rootCause.getClass().getName());
sb.append("/");
+ } else {
+ TesterException te = (TesterException) rootCause;
+ if (!"ErrorPage03 Threw Exception".equals(te.getMessage())) {
+ sb.append(" exception message is ");
+ sb.append(te.getMessage());
+ sb.append("/");
+ }
}
}
@@ -109,7 +121,7 @@
sb.append("/");
} else {
Class clazz = (Class) value;
- if (!"org.apache.tester.TesterException".equals(clazz.getName())) {
+ if (!"javax.servlet.ServletException".equals(clazz.getName())) {
sb.append(" exception_type class is ");
sb.append(clazz.getName());
sb.append("/");
1.2 +24 -11 jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java
Index: ErrorPage06.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ErrorPage06.java 2001/04/14 00:03:17 1.1
+++ ErrorPage06.java 2001/04/26 16:39:13 1.2
@@ -67,7 +67,7 @@
* the ErrorPage05 servlet returns the appropriate exception.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2001/04/14 00:03:17 $
+ * @version $Revision: 1.2 $ $Date: 2001/04/26 16:39:13 $
*/
public class ErrorPage06 extends HttpServlet {
@@ -81,18 +81,38 @@
PrintWriter writer = response.getWriter();
// Accumulate all the reasons this request might fail
+ ServletException exception = null;
+ Throwable rootCause = null;
StringBuffer sb = new StringBuffer();
Object value = null;
value = request.getAttribute("javax.servlet.error.exception");
- if (value == null)
+ if (value == null) {
sb.append(" exception is missing/");
- else if (!(value instanceof java.lang.ArithmeticException)) {
+ } else if (!(value instanceof javax.servlet.ServletException)) {
sb.append(" exception class is ");
sb.append(value.getClass().getName());
sb.append("/");
+ } else {
+ exception = (ServletException) value;
+ rootCause = exception.getRootCause();
}
+ if (rootCause == null) {
+ sb.append(" rootCause is missing/");
+ } else if (!(rootCause instanceof java.lang.ArithmeticException)) {
+ sb.append(" rootCause type is ");
+ sb.append(rootCause.getClass().getName());
+ sb.append("/");
+ } else {
+ String message = rootCause.getMessage();
+ if (!"ErrorPage05 Threw ArithmeticException".equals(message)) {
+ sb.append(" rootCause message is ");
+ sb.append(message);
+ sb.append("/");
+ }
+ }
+
value = request.getAttribute("javax.servlet.error.exception_type");
if (value == null)
sb.append(" exception_type is missing/");
@@ -102,7 +122,7 @@
sb.append("/");
} else {
Class clazz = (Class) value;
- if (!"java.lang.ArithmeticException".equals(clazz.getName())) {
+ if (!"javax.servlet.ServletException".equals(clazz.getName())) {
sb.append(" exception_type class is ");
sb.append(clazz.getName());
sb.append("/");
@@ -116,13 +136,6 @@
sb.append(" message class is ");
sb.append(value.getClass().getName());
sb.append("/");
- } else {
- String message = (String) value;
- if (!message.equals("ErrorPage05 Threw ArithmeticException")) {
- sb.append(" message content is ");
- sb.append(message);
- sb.append("/");
- }
}
value = request.getAttribute("javax.servlet.error.request_uri");