tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 Http11Processor.java
Date Wed, 14 Jan 2004 11:12:50 GMT
remm        2004/01/14 03:12:50

  Modified:    http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
  Log:
  - Correctly initialize arrays (Java is not C ;-) ).
  - Also add some logging.
  
  Revision  Changes    Path
  1.94      +33 -24    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
  
  Index: Http11Processor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Http11Processor.java	8 Jan 2004 13:08:13 -0000	1.93
  +++ Http11Processor.java	14 Jan 2004 11:12:50 -0000	1.94
  @@ -389,8 +389,11 @@
       public void addNoCompressionUserAgent(String userAgent) {
           try {
               RE nRule = new RE(userAgent);
  -            addREArray(noCompressionUserAgents, new RE(userAgent));
  -        } catch (RESyntaxException ree) {}
  +            noCompressionUserAgents = 
  +                addREArray(noCompressionUserAgents, nRule);
  +        } catch (RESyntaxException ree) {
  +            log.error("Error parsing regular expression: " + userAgent, ree);
  +        }
       }
   
   
  @@ -428,7 +431,8 @@
        * @param userAgent user-agent string
        */
       public void addCompressableMimeType(String mimeType) {
  -        addStringArray(compressableMimeTypes, mimeType);
  +        compressableMimeTypes = 
  +            addStringArray(compressableMimeTypes, mimeType);
       }
   
   
  @@ -485,10 +489,10 @@
               } else if (obj instanceof OutputFilter) {
                   outputBuffer.addFilter((OutputFilter) obj);
               } else {
  -                // Not a valid filter: log and ignore
  +                log.warn("Unknown filter: " + className);
               }
           } catch (Exception e) {
  -            // Log and ignore
  +            log.error("Error intializing filter: " + className, e);
           }
       }
   
  @@ -499,18 +503,19 @@
        * @param sArray the StringArray 
        * @param value string
        */
  -    private void addStringArray(String sArray[], String value) {
  +    private String[] addStringArray(String sArray[], String value) {
  +        String[] result = null;
           if (sArray == null) {
  -            sArray = new String[1];
  -            sArray[0] = value;
  +            result = new String[1];
  +            result[0] = value;
           }
           else {
  -            String[] results = new String[sArray.length + 1];
  +            result = new String[sArray.length + 1];
               for (int i = 0; i < sArray.length; i++)
  -                results[i] = sArray[i];
  -            results[sArray.length] = value;
  -            sArray = results;
  +                result[i] = sArray[i];
  +            result[sArray.length] = value;
           }
  +        return result;
       }
   
   
  @@ -520,18 +525,19 @@
        * @param rArray the REArray 
        * @param value Obj
        */
  -    private void addREArray(RE rArray[], RE value) {
  +    private RE[] addREArray(RE rArray[], RE value) {
  +        RE[] result = null;
           if (rArray == null) {
  -            rArray = new RE[1];
  -            rArray[0] = value;
  -        }    
  +            result = new RE[1];
  +            result[0] = value;
  +        }
           else {    
  -            RE[] results = new RE[rArray.length + 1];
  +            result = new RE[rArray.length + 1];
               for (int i = 0; i < rArray.length; i++)
  -                results[i] = rArray[i];
  -            results[rArray.length] = value;
  -            rArray = results;
  +                result[i] = rArray[i];
  +            result[rArray.length] = value;
           }
  +        return result;
       }
   
   
  @@ -579,8 +585,10 @@
       public void addRestrictedUserAgent(String userAgent) {
           try {
               RE nRule = new RE(userAgent);
  -            addREArray(restrictedUserAgents, new RE(userAgent));
  -        } catch (RESyntaxException ree) {}
  +            restrictedUserAgents = addREArray(restrictedUserAgents, nRule);
  +        } catch (RESyntaxException ree) {
  +            log.error("Error parsing regular expression: " + userAgent, ree);
  +        }
       }
   
   
  @@ -593,6 +601,7 @@
           this.restrictedUserAgents = restrictedUserAgents;
       }
   
  +
       /**
        * Set restricted user agent list (which will downgrade the connector
        * to HTTP/1.0 mode). List contains users agents separated by ',' :
  @@ -601,8 +610,8 @@
        */
       public void setRestrictedUserAgents(String restrictedUserAgents) {
           if (restrictedUserAgents != null) {
  -            StringTokenizer st = new StringTokenizer(restrictedUserAgents, ",");
  -        
  +            StringTokenizer st = 
  +                new StringTokenizer(restrictedUserAgents, ",");
               while (st.hasMoreTokens()) {
                   addRestrictedUserAgent(st.nextToken().trim());
               }
  
  
  

---------------------------------------------------------------------
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