cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1293067 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
Date Fri, 24 Feb 2012 03:34:14 GMT
Author: ffang
Date: Fri Feb 24 03:34:14 2012
New Revision: 1293067

URL: http://svn.apache.org/viewvc?rev=1293067&view=rev
Log:
[CXF-4134]GZIPOutInterceptor compiles Patterns constantly; they should be compiled once and
reused

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java?rev=1293067&r1=1293066&r2=1293067&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
Fri Feb 24 03:34:14 2012
@@ -68,6 +68,12 @@ public class GZIPOutInterceptor extends 
     public static enum UseGzip {
         NO, YES, FORCE
     }
+    
+    /**
+     * regular expression that matches any encoding with a
+     * q-value of 0 (or 0.0, 0.00, etc.).
+     */
+    public static final Pattern ZERO_Q = Pattern.compile(";\\s*q=0(?:\\.0+)?$");
 
     /**
      * Key under which we store the original output stream on the message, for
@@ -188,14 +194,11 @@ public class GZIPOutInterceptor extends 
                     List<String> zeros = new ArrayList<String>(3);
                     List<String> nonZeros = new ArrayList<String>(3);
 
-                    // regular expression that matches any encoding with a
-                    // q-value of 0 (or 0.0, 0.00, etc.).
-                    Pattern zeroQ = Pattern.compile(";\\s*q=0(?:\\.0+)?$");
                     for (String headerLine : acceptEncodingHeader) {
                         String[] encodings = headerLine.trim().split("[,\\s]*,\\s*");
 
                         for (String enc : encodings) {
-                            Matcher m = zeroQ.matcher(enc);
+                            Matcher m = ZERO_Q.matcher(enc);
                             if (m.find()) {
                                 zeros.add(enc.substring(0, m.start()));
                             } else if (enc.indexOf(';') >= 0) {



Mime
View raw message