From 836780365cbd813eb23ca18dd52a3225cfeb1083 Mon Sep 17 00:00:00 2001
From: markt
Date: Mon, 29 Jan 2007 01:45:06 +0000
Subject: [PATCH] Revert port of 39088 as per discussion on dev list.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@500918 13f79535-47bb-0310-9956-ffa450edef68
---
java/org/apache/catalina/core/StandardWrapper.java | 43 ++++++----------------
.../apache/catalina/valves/ErrorReportValve.java | 26 +++----------
webapps/docs/changelog.xml | 4 --
3 files changed, 17 insertions(+), 56 deletions(-)
diff --git a/java/org/apache/catalina/core/StandardWrapper.java b/java/org/apache/catalina/core/StandardWrapper.java
index 159da6b44..ed0003ea3 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -31,8 +31,6 @@ import java.util.Stack;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.sql.SQLException;
-
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -293,7 +291,7 @@ public class StandardWrapper
*/
protected static Properties restrictedServlets = null;
-
+
// ------------------------------------------------------------- Properties
@@ -677,37 +675,20 @@ public class StandardWrapper
* @param e The servlet exception
*/
public static Throwable getRootCause(ServletException e) {
- Throwable rootCause = e.getRootCause();
- return findRootCause(e, rootCause);
+ Throwable rootCause = e;
+ Throwable rootCauseCheck = null;
+ // Extra aggressive rootCause finding
+ int loops = 0;
+ do {
+ loops++;
+ rootCauseCheck = rootCause.getCause();
+ if (rootCauseCheck != null)
+ rootCause = rootCauseCheck;
+ } while (rootCauseCheck != null && (loops < 20));
+ return rootCause;
}
- /*
- * Work through the root causes using specific methods for well known types
- * and getCause() for the rest. Stop when the next rootCause is null or
- * an exception is found that has itself as its own rootCause.
- */
- private static final Throwable findRootCause(Throwable theException,
- Throwable theRootCause) {
-
- Throwable deeperRootCause = null;
-
- if (theRootCause == null || theRootCause == theException) {
- return theException;
- }
-
- if (theRootCause instanceof SQLException) {
- deeperRootCause = ((SQLException) theRootCause).getNextException();
- }
- if (deeperRootCause == null) {
- deeperRootCause = theRootCause.getCause();
- }
-
- return findRootCause(theRootCause, deeperRootCause);
- }
-
-
-
/**
* Refuse to add a child Container, because Wrappers are the lowest level
* of the Container hierarchy.
diff --git a/java/org/apache/catalina/valves/ErrorReportValve.java b/java/org/apache/catalina/valves/ErrorReportValve.java
index 7560df38d..a703addfb 100644
--- a/java/org/apache/catalina/valves/ErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ErrorReportValve.java
@@ -21,7 +21,6 @@ package org.apache.catalina.valves;
import java.io.IOException;
import java.io.Writer;
-import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -217,9 +216,9 @@ public class ErrorReportValve
sb.append(RequestUtil.filter(stackTrace));
sb.append("
");
+ int loops = 0;
Throwable rootCause = throwable.getCause();
- Throwable nestedRootCause = null;
- while (rootCause != null) {
+ while (rootCause != null && (loops < 10)) {
stackTrace = getPartialServletStackTrace(rootCause);
sb.append("");
sb.append(sm.getString("errorReportValve.rootCause"));
@@ -227,25 +226,10 @@ public class ErrorReportValve
sb.append(RequestUtil.filter(stackTrace));
sb.append("
");
// In case root cause is somehow heavily nested
- try {
- if (rootCause instanceof SQLException) {
- nestedRootCause = ((SQLException) rootCause).
- getNextException();
- }
- if (nestedRootCause == null) {
- nestedRootCause = rootCause.getCause();
- }
-
- if (rootCause == nestedRootCause)
- rootCause = null;
- else {
- rootCause = nestedRootCause;
- nestedRootCause = null;
- }
- } catch (ClassCastException e) {
- rootCause = null;
- }
+ rootCause = rootCause.getCause();
+ loops++;
}
+
sb.append("");
sb.append(sm.getString("errorReportValve.note"));
sb.append(" ");
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b5e39e880..5fcab1ff6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -31,10 +31,6 @@
web.xml. (markt)
- 39088: Port fix from TC5 that improved chances of finding
- the true root cause. (markt)
-
-
41217: Set secure attribute on SSO cookie when cookie is
created during a secure request. Patch provided by Chris Halstead.
(markt)
--
2.11.0