You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by jf...@apache.org on 2003/03/11 20:39:06 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ApplicationContextFacade.java StandardContext.java
jfarcand 2003/03/11 11:39:06
Modified: catalina/src/share/org/apache/catalina Context.java
catalina/src/share/org/apache/catalina/core
ApplicationContextFacade.java StandardContext.java
Log:
Better handle exceptions by propagating the cause.
When running with the SecurityManager, a Filter was having access to ApplicationContext instead of ApplicationContextFacade.
Revision Changes Path
1.5 +17 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java
Index: Context.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Context.java 23 Aug 2002 14:54:48 -0000 1.4
+++ Context.java 11 Mar 2003 19:39:06 -0000 1.5
@@ -215,6 +215,19 @@
public boolean getCrossContext();
+
+ /**
+ * Return the alternate Deployment Descriptor name.
+ */
+ public String getAltDDName();
+
+
+ /**
+ * Set an alternate Deployment Descriptor name.
+ */
+ public void setAltDDName(String altDDName) ;
+
+
/**
* Set the "allow crossing servlet contexts" flag.
*
1.3 +31 -14 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContextFacade.java
Index: ApplicationContextFacade.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContextFacade.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApplicationContextFacade.java 4 Mar 2003 01:57:05 -0000 1.2
+++ ApplicationContextFacade.java 11 Mar 2003 19:39:06 -0000 1.3
@@ -104,8 +104,7 @@
public final class ApplicationContextFacade
implements ServletContext {
-
-
+
// ---------------------------------------------------------- Attributes
/**
* Cache Class object used for reflection.
@@ -228,7 +227,7 @@
public Servlet getServlet(String name)
throws ServletException {
- return (Servlet)doPrivileged("getServlet", null);
+ return (Servlet)doPrivileged("getServlet", new Object[]{name});
}
@@ -243,7 +242,7 @@
public void log(String msg) {
- context.log(msg);
+ doPrivileged("log", new Object[]{msg} );
}
@@ -327,11 +326,20 @@
}
return executeMethod(method,appContext,params);
- } catch (Exception ex){
+ } catch (Throwable ex){
+ Throwable exception;
+ if (ex instanceof InvocationTargetException){
+ exception = ((InvocationTargetException)ex).getTargetException();
+ } else if (ex instanceof PrivilegedActionException){
+ exception = ((PrivilegedActionException)ex).getException();
+ } else {
+ exception = ex;
+ }
+
if (log.isErrorEnabled()){
- log.error("doPrivileged", ex);
+ log.error("doPrivileged", exception);
}
- return null;
+ throw new RuntimeException(ex.getMessage());
}
}
@@ -350,11 +358,20 @@
Method method = context.getClass()
.getMethod(methodName, (Class[])clazz);
return executeMethod(method,context,params);
- } catch (Exception ex){
+ } catch (Throwable ex){
+ Throwable exception;
+ if (ex instanceof InvocationTargetException){
+ exception = ((InvocationTargetException)ex).getTargetException();
+ } else if (ex instanceof PrivilegedActionException){
+ exception = ((PrivilegedActionException)ex).getException();
+ } else {
+ exception = ex;
+ }
+
if (log.isErrorEnabled()){
- log.error("doPrivileged", ex);
+ log.error("doPrivileged", exception);
}
- return null;
+ throw new RuntimeException(ex.getMessage());
}
}
1.24 +14 -5 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
Index: StandardContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- StandardContext.java 5 Mar 2003 19:09:26 -0000 1.23
+++ StandardContext.java 11 Mar 2003 19:39:06 -0000 1.24
@@ -790,6 +790,15 @@
}
+
+ /**
+ * Return the alternate Deployment Descriptor name.
+ */
+ public String getAltDDName(){
+ return altDDName;
+ }
+
+
/**
* Set an alternate Deployment Descriptor name.
*/
@@ -1138,7 +1147,7 @@
if (altDDName != null)
context.setAttribute(Globals.ALT_DD_ATTR,altDDName);
}
- return (context);
+ return (context.getFacade());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org