jfarcand 2004/09/30 18:10:17 Modified: catalina/src/share/org/apache/catalina/core Tag: TOMCAT_5_0 ApplicationContextFacade.java ApplicationFilterChain.java StandardWrapper.java Log: Rollback wrong logic. Revision Changes Path No revision No revision 1.10.2.2 +28 -55 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.10.2.1 retrieving revision 1.10.2.2 diff -u -r1.10.2.1 -r1.10.2.2 --- ApplicationContextFacade.java 30 Sep 2004 15:53:31 -0000 1.10.2.1 +++ ApplicationContextFacade.java 1 Oct 2004 01:10:17 -0000 1.10.2.2 @@ -52,13 +52,8 @@ /** * Cache Class object used for reflection. */ - private static HashMap classCache = new HashMap(); + private HashMap classCache; - static { - if (System.getSecurityManager() != null) { - initClassCache(); - } - } /** * Cache method object. @@ -69,13 +64,7 @@ private static org.apache.commons.logging.Log sysLog= org.apache.commons.logging.LogFactory.getLog( ApplicationContextFacade.class ); - - /** - * Object repository used when the SecurityManager is turned on and - * Filter.doFilter is invoked. - */ - private Object[] objectArg = new Object[1]; - private Object[] objectArgs = new Object[2]; + // ----------------------------------------------------------- Constructors @@ -89,12 +78,13 @@ super(); this.context = context; + classCache = new HashMap(); objectCache = new HashMap(); - + initClassCache(); } - private static void initClassCache(){ + private void initClassCache(){ Class[] clazz = new Class[]{String.class}; classCache.put("getContext", clazz); classCache.put("getMimeType", clazz); @@ -129,8 +119,8 @@ public ServletContext getContext(String uripath) { ServletContext theContext = null; if (System.getSecurityManager() != null) { - objectArg[0] = uripath; - theContext = (ServletContext)doPrivileged("getContext", objectArg); + theContext = (ServletContext) + doPrivileged("getContext", new Object[]{uripath}); } else { theContext = context.getContext(uripath); } @@ -154,8 +144,7 @@ public String getMimeType(String file) { if (System.getSecurityManager() != null) { - objectArg[0] = file; - return (String)doPrivileged("getMimeType", objectArg); + return (String)doPrivileged("getMimeType", new Object[]{file}); } else { return context.getMimeType(file); } @@ -164,8 +153,7 @@ public Set getResourcePaths(String path) { if (System.getSecurityManager() != null){ - objectArg[0] = path; - return (Set)doPrivileged("getResourcePaths", objectArg); + return (Set)doPrivileged("getResourcePaths", new Object[]{path}); } else { return context.getResourcePaths(path); } @@ -176,9 +164,8 @@ throws MalformedURLException { if (System.getSecurityManager() != null) { try { - objectArg[0] = path; return (URL) invokeMethod(context, "getResource", - objectArg); + new Object[]{path}); } catch(Throwable t) { if (t instanceof MalformedURLException){ throw (MalformedURLException)t; @@ -193,9 +180,8 @@ public InputStream getResourceAsStream(String path) { if (System.getSecurityManager() != null) { - objectArg[0] = path; return (InputStream) doPrivileged("getResourceAsStream", - objectArg); + new Object[]{path}); } else { return context.getResourceAsStream(path); } @@ -204,9 +190,8 @@ public RequestDispatcher getRequestDispatcher(final String path) { if (System.getSecurityManager() != null) { - objectArg[0] = path; return (RequestDispatcher) doPrivileged("getRequestDispatcher", - objectArg); + new Object[]{path}); } else { return context.getRequestDispatcher(path); } @@ -215,9 +200,8 @@ public RequestDispatcher getNamedDispatcher(String name) { if (System.getSecurityManager() != null) { - objectArg[0] = name; return (RequestDispatcher) doPrivileged("getNamedDispatcher", - objectArg); + new Object[]{name}); } else { return context.getNamedDispatcher(name); } @@ -228,9 +212,8 @@ throws ServletException { if (System.getSecurityManager() != null) { try { - objectArg[0] = name; return (Servlet) invokeMethod(context, "getServlet", - objectArg); + new Object[]{name}); } catch (Throwable t) { if (t instanceof ServletException) { throw (ServletException) t; @@ -263,8 +246,7 @@ public void log(String msg) { if (System.getSecurityManager() != null) { - objectArg[0] = msg; - doPrivileged("log", objectArg ); + doPrivileged("log", new Object[]{msg} ); } else { context.log(msg); } @@ -283,10 +265,8 @@ public void log(String message, Throwable throwable) { if (System.getSecurityManager() != null) { - objectArgs[0] = message; - objectArgs[1] = throwable; doPrivileged("log", new Class[]{String.class, Throwable.class}, - objectArgs); + new Object[]{message, throwable}); } else { context.log(message, throwable); } @@ -295,8 +275,7 @@ public String getRealPath(String path) { if (System.getSecurityManager() != null) { - objectArg[0] = path; - return (String) doPrivileged("getRealPath", objectArg); + return (String) doPrivileged("getRealPath", new Object[]{path}); } else { return context.getRealPath(path); } @@ -314,9 +293,8 @@ public String getInitParameter(String name) { if (System.getSecurityManager() != null) { - objectArg[0] = name; return (String) doPrivileged("getInitParameter", - objectArg); + new Object[]{name}); } else { return context.getInitParameter(name); } @@ -334,8 +312,7 @@ public Object getAttribute(String name) { if (System.getSecurityManager() != null) { - objectArg[0] = name; - return doPrivileged("getAttribute", objectArg); + return doPrivileged("getAttribute", new Object[]{name}); } else { return context.getAttribute(name); } @@ -343,7 +320,7 @@ public Enumeration getAttributeNames() { - if (System.getSecurityManager() != null) { + if (System.getSecurityManager() != null) { return (Enumeration) doPrivileged("getAttributeNames", null); } else { return context.getAttributeNames(); @@ -353,9 +330,7 @@ public void setAttribute(String name, Object object) { if (System.getSecurityManager() != null) { - objectArgs[0] = name; - objectArgs[1] = object; - doPrivileged("setAttribute", objectArgs); + doPrivileged("setAttribute", new Object[]{name,object}); } else { context.setAttribute(name, object); } @@ -364,8 +339,7 @@ public void removeAttribute(String name) { if (System.getSecurityManager() != null) { - objectArg[0] = name; - doPrivileged("removeAttribute", objectArg); + doPrivileged("removeAttribute", new Object[]{name}); } else { context.removeAttribute(name); } @@ -395,7 +369,7 @@ try{ return invokeMethod(appContext, methodName, params ); } catch (Throwable t){ - throw new RuntimeException(t); + throw new RuntimeException(t.getMessage()); } } @@ -412,7 +386,7 @@ try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ - throw new RuntimeException(t); + throw new RuntimeException(t.getMessage()); } } @@ -448,9 +422,8 @@ /** * Use reflection to invoke the requested method. Cache the method object * to speed up the process - * @param appContext The AppliationContext object on which the method - * will be invoked - * @param methodName The method to call. + * @param methodName The method to invoke. + * @param clazz The class where the method is. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, @@ -465,7 +438,7 @@ try{ handleException(ex, methodName); }catch (Throwable t){ - throw new RuntimeException(t); + throw new RuntimeException(t.getMessage()); } return null; } 1.10.2.2 +11 -41 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationFilterChain.java Index: ApplicationFilterChain.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationFilterChain.java,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -r1.10.2.1 -r1.10.2.2 --- ApplicationFilterChain.java 30 Sep 2004 15:53:31 -0000 1.10.2.1 +++ ApplicationFilterChain.java 1 Oct 2004 01:10:17 -0000 1.10.2.2 @@ -111,35 +111,6 @@ */ private InstanceSupport support = null; - - /** - * Static class array used when the SecurityManager is turned on and - * <code>doFilter</code is invoked. - */ - private static Class[] classType = new Class[]{ServletRequest.class, - ServletResponse.class, - FilterChain.class}; - - /** - * Static class array used when the SecurityManager is turned on and - * <code>service</code is invoked. - */ - private static Class[] classTypeUsedInService = new Class[]{ - ServletRequest.class, - ServletResponse.class}; - - /** - * Object repository used when the SecurityManager is turned on and - * Filter.doFilter is invoked. - */ - private Object[] filterType = new Object[3]; - - - /** - * Object repository used when the SecurityManager is turned on and - * Filter.doFilter is invoked. - */ - private Object[] serviceType = new Object[2]; // ---------------------------------------------------- FilterChain Methods @@ -205,12 +176,12 @@ final ServletResponse res = response; Principal principal = ((HttpServletRequest) req).getUserPrincipal(); - - filterType[0] = req; - filterType[1] = res; - filterType[2] = this; + Class[] classType = new Class[]{ServletRequest.class, + ServletResponse.class, + FilterChain.class}; + Object[] args = new Object[]{req, res, this}; SecurityUtil.doAsPrivilege - ("doFilter", filter, classType, filterType); + ("doFilter", filter, classType, args); } else { filter.doFilter(request, response, this); } @@ -254,15 +225,14 @@ final ServletResponse res = response; Principal principal = ((HttpServletRequest) req).getUserPrincipal(); - - serviceType[0] = req; - serviceType[1] = res; - + Class[] classType = new Class[]{ServletRequest.class, + ServletResponse.class}; + Object[] args = new Object[]{req, res}; SecurityUtil.doAsPrivilege("service", servlet, - classTypeUsedInService, - serviceType, - principal); + classType, + args, + principal); } else { servlet.service((HttpServletRequest) request, (HttpServletResponse) response); 1.43.2.2 +8 -35 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java Index: StandardWrapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v retrieving revision 1.43.2.1 retrieving revision 1.43.2.2 diff -u -r1.43.2.1 -r1.43.2.2 --- StandardWrapper.java 30 Sep 2004 15:53:31 -0000 1.43.2.1 +++ StandardWrapper.java 1 Oct 2004 01:10:17 -0000 1.43.2.2 @@ -240,35 +240,6 @@ private long loadTime=0; private int classLoadTime=0; - - /** - * Static class array used when the SecurityManager is turned on and - * <code>Servlet.init</code> is invoked. - */ - private static Class[] classType = new Class[]{ServletConfig.class}; - - - /** - * Object repository used when the SecurityManager is turned on and - * <code>Servlet.init</code> is invoked. - */ - private Object[] initType = new Object[1]; - - - /** - * Static class array used when the SecurityManager is turned on and - * <code>Servlet.service</code> is invoked. - */ - private static Class[] classTypeUsedInService = new Class[]{ - ServletRequest.class, - ServletResponse.class}; - - - /** - * Object repository used when the SecurityManager is turned on and - * <code>Servlet.service</code> is invoked. - */ - private Object[] serviceType = new Object[2]; // ------------------------------------------------------------- Properties @@ -1048,11 +1019,12 @@ servlet); if( System.getSecurityManager() != null) { - initType[0] = facade; + Class[] classType = new Class[]{ServletConfig.class}; + Object[] args = new Object[]{((ServletConfig)facade)}; SecurityUtil.doAsPrivilege("init", servlet, classType, - initType); + args); } else { servlet.init(facade); } @@ -1066,12 +1038,13 @@ DummyResponse res = new DummyResponse(); if( System.getSecurityManager() != null) { - serviceType[0] = req; - serviceType[1] = res; + Class[] classType = new Class[]{ServletRequest.class, + ServletResponse.class}; + Object[] args = new Object[]{req, res}; SecurityUtil.doAsPrivilege("service", servlet, - classTypeUsedInService, - serviceType); + classType, + args); } else { servlet.service(req, res); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]