tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfarc...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteInputStream.java CoyoteRequestFacade.java CoyoteResponse.java CoyoteResponseFacade.java InputBuffer.java OutputBuffer.java
Date Thu, 18 Nov 2004 22:14:25 GMT
jfarcand    2004/11/18 14:14:25

  Modified:    catalina/src/share/org/apache/coyote/tomcat5 Tag: TOMCAT_5_0
                        CoyoteInputStream.java CoyoteRequestFacade.java
                        CoyoteResponse.java CoyoteResponseFacade.java
                        InputBuffer.java OutputBuffer.java
  Log:
  When the package protection is not used, do not create the doPrivileged objects so we don't
suffer the performance hit (15% faster with trade2 and this change). Also fixed a memory leak
when security manager is turned on.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.5.2.1   +6 -5      jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteInputStream.java
  
  Index: CoyoteInputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteInputStream.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- CoyoteInputStream.java	14 Apr 2004 00:14:22 -0000	1.5
  +++ CoyoteInputStream.java	18 Nov 2004 22:14:24 -0000	1.5.2.1
  @@ -24,6 +24,7 @@
   
   import javax.servlet.ServletInputStream;
   
  +import org.apache.catalina.security.SecurityUtil;
   
   /**
    * This class handles reading bytes.
  @@ -65,7 +66,7 @@
   
       public int read()
           throws IOException {    
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               
               try{
                   Integer result = 
  @@ -94,7 +95,7 @@
   
       public int available() throws IOException {
           
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               try{
                   Integer result = 
                       (Integer)AccessController.doPrivileged(
  @@ -122,7 +123,7 @@
   
       public int read(final byte[] b) throws IOException {
           
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               try{
                   Integer result = 
                       (Integer)AccessController.doPrivileged(
  @@ -153,7 +154,7 @@
       public int read(final byte[] b, final int off, final int len)
           throws IOException {
               
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               try{
                   Integer result = 
                       (Integer)AccessController.doPrivileged(
  @@ -193,7 +194,7 @@
        */
       public void close() throws IOException {
           
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               try{
                   AccessController.doPrivileged(
                       new PrivilegedExceptionAction(){
  
  
  
  1.7.2.1   +16 -14    jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteRequestFacade.java
  
  Index: CoyoteRequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteRequestFacade.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- CoyoteRequestFacade.java	2 Mar 2004 17:36:55 -0000	1.7
  +++ CoyoteRequestFacade.java	18 Nov 2004 22:14:24 -0000	1.7.2.1
  @@ -33,6 +33,8 @@
   
   import org.apache.catalina.connector.RequestFacade;
   
  +import org.apache.catalina.security.SecurityUtil;
  +
   /**
    * Facade class that wraps a Coyote request object.  
    * All methods are delegated to the wrapped request.
  @@ -216,7 +218,7 @@
   
   
       public Enumeration getAttributeNames() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Enumeration)AccessController.doPrivileged(
                   new GetAttributePrivilegedAction());        
           } else {
  @@ -226,7 +228,7 @@
   
   
       public String getCharacterEncoding() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (String)AccessController.doPrivileged(
                   new GetCharacterEncodingPrivilegedAction());
           } else {
  @@ -258,7 +260,7 @@
   
   
       public String getParameter(String name) {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (String)AccessController.doPrivileged(
                   new GetParameterPrivilegedAction(name));
           } else {
  @@ -268,7 +270,7 @@
   
   
       public Enumeration getParameterNames() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Enumeration)AccessController.doPrivileged(
                   new GetParameterNamesPrivilegedAction());
           } else {
  @@ -285,7 +287,7 @@
            * Clone the returned array only if there is a security manager
            * in place, so that performance won't suffer in the nonsecure case
            */
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               ret = (String[]) AccessController.doPrivileged(
                   new GetParameterValuePrivilegedAction(name));
               if (ret != null) {
  @@ -300,7 +302,7 @@
   
   
       public Map getParameterMap() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Map)AccessController.doPrivileged(
                   new GetParameterMapPrivilegedAction());        
           } else {
  @@ -356,7 +358,7 @@
   
   
       public Locale getLocale() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Locale)AccessController.doPrivileged(
                   new GetLocalePrivilegedAction());
           } else {
  @@ -366,7 +368,7 @@
   
   
       public Enumeration getLocales() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Enumeration)AccessController.doPrivileged(
                   new GetLocalesPrivilegedAction());
           } else {
  @@ -381,7 +383,7 @@
   
   
       public RequestDispatcher getRequestDispatcher(String path) {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (RequestDispatcher)AccessController.doPrivileged(
                   new GetRequestDispatcherPrivilegedAction(path));
           } else {
  @@ -408,7 +410,7 @@
            * Clone the returned array only if there is a security manager
            * in place, so that performance won't suffer in the nonsecure case
            */
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               ret = (Cookie[])AccessController.doPrivileged(
                   new GetCookiesPrivilegedAction());
               if (ret != null) {
  @@ -433,7 +435,7 @@
   
   
       public Enumeration getHeaders(String name) {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Enumeration)AccessController.doPrivileged(
                   new GetHeadersPrivilegedAction(name));
           } else {
  @@ -443,7 +445,7 @@
   
   
       public Enumeration getHeaderNames() {
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (Enumeration)AccessController.doPrivileged(
                   new GetHeaderNamesPrivilegedAction());
           } else {
  @@ -519,7 +521,7 @@
   
       public HttpSession getSession(boolean create) {
   
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               return (HttpSession)AccessController.
                   doPrivileged(new GetSessionPrivilegedAction(create));
           } else {
  
  
  
  1.18.2.2  +5 -4      jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteResponse.java
  
  Index: CoyoteResponse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteResponse.java,v
  retrieving revision 1.18.2.1
  retrieving revision 1.18.2.2
  diff -u -r1.18.2.1 -r1.18.2.2
  --- CoyoteResponse.java	23 Aug 2004 19:22:20 -0000	1.18.2.1
  +++ CoyoteResponse.java	18 Nov 2004 22:14:24 -0000	1.18.2.2
  @@ -47,6 +47,7 @@
   import org.apache.catalina.util.CharsetMapper;
   import org.apache.catalina.util.DateTool;
   import org.apache.catalina.util.StringManager;
  +import org.apache.catalina.security.SecurityUtil;
   import org.apache.coyote.Response;
   import org.apache.tomcat.util.buf.CharChunk;
   import org.apache.tomcat.util.buf.UEncoder;
  @@ -934,7 +935,7 @@
           cookies.add(cookie);
   
           final StringBuffer sb = new StringBuffer();
  -        if (System.getSecurityManager() != null) {
  +        if (SecurityUtil.isPackageProtectionEnabled()) {
               AccessController.doPrivileged(new PrivilegedAction() {
                   public Object run(){
                       ServerCookie.appendCookieValue
  @@ -1359,7 +1360,7 @@
           if (hreq.isRequestedSessionIdFromCookie())
               return (false);
           
  -        if (System.getSecurityManager() != null) {
  +        if (SecurityUtil.isPackageProtectionEnabled()) {
               return ((Boolean)
                   AccessController.doPrivileged(new PrivilegedAction() {
   
  @@ -1463,7 +1464,7 @@
                       
                       String encodedURI = null;
                       final String frelativePath = relativePath;
  -                    if (System.getSecurityManager() != null ){
  +                    if (SecurityUtil.isPackageProtectionEnabled() ){
                           try{
                               encodedURI = (String)AccessController.doPrivileged( 
                                   new PrivilegedExceptionAction(){                      
         
  
  
  
  1.4.2.1   +4 -3      jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteResponseFacade.java
  
  Index: CoyoteResponseFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/CoyoteResponseFacade.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- CoyoteResponseFacade.java	27 Feb 2004 14:58:53 -0000	1.4
  +++ CoyoteResponseFacade.java	18 Nov 2004 22:14:24 -0000	1.4.2.1
  @@ -29,6 +29,7 @@
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletResponse;
   
  +import org.apache.catalina.security.SecurityUtil;
   import org.apache.catalina.connector.ResponseFacade;
   
   /**
  @@ -183,7 +184,7 @@
           if (isCommitted())
               return;
           
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               AccessController.doPrivileged(new SetContentTypePrivilegedAction(type));
           } else {
               response.setContentType(type);            
  @@ -215,7 +216,7 @@
               //                (/*sm.getString("responseFacade.finished")*/);
               return;
   
  -        if (System.getSecurityManager() != null){
  +        if (SecurityUtil.isPackageProtectionEnabled()){
               try{
                   AccessController.doPrivileged(new PrivilegedExceptionAction(){
   
  
  
  
  1.7.2.1   +2 -1      jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/InputBuffer.java
  
  Index: InputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/InputBuffer.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- InputBuffer.java	14 May 2004 21:14:14 -0000	1.7
  +++ InputBuffer.java	18 Nov 2004 22:14:24 -0000	1.7.2.1
  @@ -23,6 +23,7 @@
   import java.security.PrivilegedExceptionAction;
   import java.util.HashMap;
   
  +import org.apache.catalina.security.SecurityUtil;
   import org.apache.coyote.Request;
   import org.apache.tomcat.util.buf.B2CConverter;
   import org.apache.tomcat.util.buf.ByteChunk;
  @@ -482,7 +483,7 @@
               enc = DEFAULT_ENCODING;
           conv = (B2CConverter) encoders.get(enc);
           if (conv == null) {
  -            if (System.getSecurityManager() != null){
  +            if (SecurityUtil.isPackageProtectionEnabled()){
                   try{
                       conv = (B2CConverter)AccessController.doPrivileged(
                               new PrivilegedExceptionAction(){
  
  
  
  1.8.2.1   +2 -1      jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/Attic/OutputBuffer.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- OutputBuffer.java	27 Feb 2004 14:58:53 -0000	1.8
  +++ OutputBuffer.java	18 Nov 2004 22:14:24 -0000	1.8.2.1
  @@ -25,6 +25,7 @@
   import java.util.HashMap;
   
   import org.apache.catalina.connector.ClientAbortException;
  +import org.apache.catalina.security.SecurityUtil;
   import org.apache.coyote.ActionCode;
   import org.apache.coyote.Response;
   import org.apache.tomcat.util.buf.ByteChunk;
  @@ -596,7 +597,7 @@
           conv = (C2BConverter) encoders.get(enc);
           if (conv == null) {
               
  -            if (System.getSecurityManager() != null){
  +            if (SecurityUtil.isPackageProtectionEnabled()){
                   try{
                       conv = (C2BConverter)AccessController.doPrivileged(
                               new PrivilegedExceptionAction(){
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message