cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6204] Ending up doing the right code
Date Mon, 19 Jan 2015 17:12:40 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 864f9e456 -> f6104b340


[CXF-6204] Ending up doing the right code


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f6104b34
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f6104b34
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f6104b34

Branch: refs/heads/master
Commit: f6104b34015431da86515ddcc8733ca164d97a39
Parents: 864f9e4
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Jan 19 17:12:23 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Jan 19 17:12:23 2015 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/NewCookieHeaderProvider.java | 40 +++++++++-----------
 .../jaxrs/impl/NewCookieHeaderProviderTest.java |  2 +-
 2 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f6104b34/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
index 63b8819..a050b86 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
@@ -33,7 +33,7 @@ public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie>
{
     private static final String COMMENT = "Comment";
     private static final String SECURE = "Secure";
     private static final String EXPIRES = "Expires";
-    
+        
     public NewCookie fromString(String c) {
         
         if (c == null) {
@@ -51,31 +51,27 @@ public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie>
{
         String[] tokens = StringUtils.split(c, ";");
         for (String token : tokens) {
             String theToken = token.trim();
-            String theTokenUC = theToken;
-            if (!StringUtils.isEmpty(theTokenUC) && Character.isLowerCase(theTokenUC.charAt(0)))
{
-                theTokenUC = StringUtils.capitalize(theToken);
-            }
-            if (theTokenUC.startsWith(VERSION)) {
-                // should we throw an exception if it's not == 1 ?
-            } else if (theTokenUC.startsWith(MAX_AGE)) {
-                maxAge = Integer.parseInt(theTokenUC.substring(MAX_AGE.length() + 1));
-            } else if (theTokenUC.startsWith(PATH)) {
-                path = theTokenUC.substring(PATH.length() + 1);
-            } else if (theTokenUC.startsWith(DOMAIN)) {
-                domain = theTokenUC.substring(DOMAIN.length() + 1);
-            } else if (theTokenUC.startsWith(COMMENT)) {
-                comment = theTokenUC.substring(COMMENT.length() + 1);
-            } else if (theTokenUC.startsWith(SECURE)) {
+            
+            int sepIndex = theToken.indexOf('=');
+            String paramName = sepIndex != -1 ? theToken.substring(0, sepIndex) : theToken;
+            String paramValue = sepIndex == theToken.length() + 1 ? null : theToken.substring(sepIndex
+ 1);
+            
+            if (paramName.equalsIgnoreCase(MAX_AGE)) {
+                maxAge = Integer.parseInt(paramValue);
+            } else if (paramName.equalsIgnoreCase(PATH)) {
+                path = paramValue;
+            } else if (paramName.equalsIgnoreCase(DOMAIN)) {
+                domain = paramValue;
+            } else if (paramName.equalsIgnoreCase(COMMENT)) {
+                comment = paramValue;
+            } else if (paramName.equalsIgnoreCase(SECURE)) {
                 isSecure = true;
-            } else if (theTokenUC.startsWith(EXPIRES)) {
+            } else if (paramName.equalsIgnoreCase(EXPIRES) || paramName.equalsIgnoreCase(VERSION))
{
                 // ignore
                 continue;
             } else {
-                int i = theToken.indexOf('=');
-                if (i != -1) {
-                    name = theToken.substring(0, i);
-                    value = i == theToken.length()  + 1 ? "" : theToken.substring(i + 1);
-                }
+                name = paramName;
+                value = paramValue;
             }
         }
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/f6104b34/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
index 9b2b51e..6e62952 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java
@@ -62,7 +62,7 @@ public class NewCookieHeaderProviderTest extends Assert {
     @Test
     public void testFromComplexStringLowerCase() {
         NewCookie c = NewCookie.valueOf(
-                      "foo=bar;comment=comment;path=path;max-Age=10;domain=domain;secure;version=1");
+                      "foo=bar;comment=comment;path=path;max-age=10;domain=domain;secure;version=1");
         assertTrue("bar".equals(c.getValue())
                    && "foo".equals(c.getName())
                    && 1 == c.getVersion()


Mime
View raw message