hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1620612 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http: cookie/ impl/cookie/
Date Tue, 26 Aug 2014 14:37:37 GMT
Author: olegk
Date: Tue Aug 26 14:37:36 2014
New Revision: 1620612

URL: http://svn.apache.org/r1620612
Log:
Made all cookie spec implementations thread safe

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CommonCookieAttributeHandler.java
      - copied, changed from r1619782, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CommonCookieAttributeHandler.java (from r1619782, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CommonCookieAttributeHandler.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CommonCookieAttributeHandler.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java&r1=1619782&r2=1620612&rev=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CommonCookieAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -24,29 +24,17 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.impl.cookie;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
+package org.apache.http.cookie;
 
 /**
+ * Extension of {@link org.apache.http.cookie.CookieAttributeHandler} intended
+ * to handle one specific common attribute whose name is returned with
+ * {@link #getAttributeName()} method.
  *
- * @since 4.0
+ * @since 4.4
  */
-@Immutable
-public class BasicCommentHandler extends AbstractCookieAttributeHandler {
-
-    public BasicCommentHandler() {
-        super();
-    }
+public interface CommonCookieAttributeHandler extends CookieAttributeHandler {
 
-    @Override
-    public void parse(final SetCookie cookie, final String value)
-            throws MalformedCookieException {
-        Args.notNull(cookie, "Cookie");
-        cookie.setComment(value);
-    }
+    String getAttributeName();
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java Tue Aug 26 14:37:36 2014
@@ -30,11 +30,14 @@ package org.apache.http.impl.cookie;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieSpec;
 import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 
 /**
  * Abstract cookie specification which can delegate the job of parsing,
@@ -44,7 +47,7 @@ import org.apache.http.util.Args;
  *
  * @since 4.0
  */
-@NotThreadSafe // HashMap is not thread-safe
+@ThreadSafe
 public abstract class AbstractCookieSpec implements CookieSpec {
 
     /**
@@ -57,9 +60,35 @@ public abstract class AbstractCookieSpec
      * */
     public AbstractCookieSpec() {
         super();
-        this.attribHandlerMap = new HashMap<String, CookieAttributeHandler>(10);
+        this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(10);
     }
 
+    /**
+     * @since 4.4
+     */
+    protected AbstractCookieSpec(final HashMap<String, CookieAttributeHandler> map) {
+        super();
+        Asserts.notNull(map, "Attribute handler map");
+        this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(map);
+    }
+
+    /**
+     * @since 4.4
+     */
+    protected AbstractCookieSpec(final CommonCookieAttributeHandler... handlers) {
+        super();
+        this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(handlers.length);
+        for (CommonCookieAttributeHandler handler: handlers) {
+            this.attribHandlerMap.put(handler.getAttributeName(), handler);
+        }
+    }
+
+    /**
+     * @deprecated (4.4) use {@link #AbstractCookieSpec(java.util.HashMap)} or
+     *  {@link #AbstractCookieSpec(org.apache.http.cookie.CommonCookieAttributeHandler...)}
+     *  constructors instead.
+     */
+    @Deprecated
     public void registerAttribHandler(
             final String name, final CookieAttributeHandler handler) {
         Args.notNull(name, "Attribute name");
@@ -89,12 +118,9 @@ public abstract class AbstractCookieSpec
      */
     protected CookieAttributeHandler getAttribHandler(final String name) {
         final CookieAttributeHandler handler = findAttribHandler(name);
-        if (handler == null) {
-            throw new IllegalStateException("Handler not registered for " +
-                                            name + " attribute.");
-        } else {
-            return handler;
-        }
+        Asserts.check(handler != null, "Handler not registered for " +
+                name + " attribute");
+        return handler;
     }
 
     protected Collection<CookieAttributeHandler> getAttribHandlers() {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java Tue Aug 26 14:37:36 2014
@@ -27,6 +27,8 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.Args;
@@ -36,7 +38,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class BasicCommentHandler extends AbstractCookieAttributeHandler {
+public class BasicCommentHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     public BasicCommentHandler() {
         super();
@@ -49,4 +51,9 @@ public class BasicCommentHandler extends
         cookie.setComment(value);
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.COMMENT_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java Tue Aug 26 14:37:36 2014
@@ -27,8 +27,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -40,7 +41,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class BasicDomainHandler implements CookieAttributeHandler {
+public class BasicDomainHandler implements CommonCookieAttributeHandler {
 
     public BasicDomainHandler() {
         super();
@@ -116,4 +117,9 @@ public class BasicDomainHandler implemen
         return host.endsWith(domain) || host.equals(domain.substring(1));
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.DOMAIN_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java Tue Aug 26 14:37:36 2014
@@ -30,6 +30,8 @@ import java.util.Date;
 
 import org.apache.http.annotation.Immutable;
 import org.apache.http.client.utils.DateUtils;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.Args;
@@ -39,7 +41,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class BasicExpiresHandler extends AbstractCookieAttributeHandler {
+public class BasicExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     /** Valid date patterns */
     private final String[] datepatterns;
@@ -64,4 +66,9 @@ public class BasicExpiresHandler extends
         cookie.setExpiryDate(expiry);
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.EXPIRES_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java Tue Aug 26 14:37:36 2014
@@ -29,6 +29,8 @@ package org.apache.http.impl.cookie;
 import java.util.Date;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.Args;
@@ -38,7 +40,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler {
+public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     public BasicMaxAgeHandler() {
         super();
@@ -65,4 +67,9 @@ public class BasicMaxAgeHandler extends 
         cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.MAX_AGE_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java Tue Aug 26 14:37:36 2014
@@ -27,8 +27,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -41,7 +42,7 @@ import org.apache.http.util.TextUtils;
  * @since 4.0
  */
 @Immutable
-public class BasicPathHandler implements CookieAttributeHandler {
+public class BasicPathHandler implements CommonCookieAttributeHandler {
 
     public BasicPathHandler() {
         super();
@@ -87,4 +88,9 @@ public class BasicPathHandler implements
         return match;
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.PATH_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java Tue Aug 26 14:37:36 2014
@@ -27,6 +27,8 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
@@ -38,7 +40,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class BasicSecureHandler extends AbstractCookieAttributeHandler {
+public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     public BasicSecureHandler() {
         super();
@@ -58,4 +60,9 @@ public class BasicSecureHandler extends 
         return !cookie.isSecure() || origin.isSecure();
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.SECURE_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java Tue Aug 26 14:37:36 2014
@@ -32,7 +32,7 @@ import java.util.List;
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
@@ -49,48 +49,30 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-@NotThreadSafe // CookieSpec fields are @NotThreadSafe
+@ThreadSafe
 public class BestMatchSpec implements CookieSpec {
 
-    private final String[] datepatterns;
-    private final boolean oneHeader;
-
-    // Cached values of CookieSpec instances
-    private RFC2965Spec strict; // @NotThreadSafe
-    private RFC2109Spec obsoleteStrict; // @NotThreadSafe
-    private NetscapeDraftSpec netscape; // @NotThreadSafe
+    private final RFC2965Spec strict;
+    private final RFC2109Spec obsoleteStrict;
+    private final NetscapeDraftSpec netscapeDraft;
 
     public BestMatchSpec(final String[] datepatterns, final boolean oneHeader) {
         super();
-        this.datepatterns = datepatterns == null ? null : datepatterns.clone();
-        this.oneHeader = oneHeader;
+        this.strict = new RFC2965Spec(datepatterns, oneHeader);
+        this.obsoleteStrict = new RFC2109Spec(datepatterns, oneHeader);
+        this.netscapeDraft = new NetscapeDraftSpec(
+                new BasicDomainHandler(),
+                new BasicPathHandler(),
+                new BasicSecureHandler(),
+                new BasicCommentHandler(),
+                new BasicExpiresHandler(
+                        datepatterns != null ? datepatterns.clone() : new String[]{NetscapeDraftSpec.EXPIRES_PATTERN}));
     }
 
     public BestMatchSpec() {
         this(null, false);
     }
 
-    private RFC2965Spec getStrict() {
-        if (this.strict == null) {
-             this.strict = new RFC2965Spec(this.datepatterns, this.oneHeader);
-        }
-        return strict;
-    }
-
-    private RFC2109Spec getObsoleteStrict() {
-        if (this.obsoleteStrict == null) {
-             this.obsoleteStrict = new RFC2109Spec(this.datepatterns, this.oneHeader);
-        }
-        return obsoleteStrict;
-    }
-
-    private NetscapeDraftSpec getNetscapeCompat() {
-        if (this.netscape == null) {
-            this.netscape = new NetscapeDraftSpec(false, this.datepatterns);
-        }
-        return netscape;
-    }
-
     @Override
     public List<Cookie> parse(
             final Header header,
@@ -129,12 +111,12 @@ public class BestMatchSpec implements Co
                 cursor = new ParserCursor(0, buffer.length());
             }
             helems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
-            return getNetscapeCompat().parse(helems, origin);
+            return netscapeDraft.parse(helems, origin);
         } else {
             if (SM.SET_COOKIE2.equals(header.getName())) {
-                return getStrict().parse(helems, origin);
+                return strict.parse(helems, origin);
             } else {
-                return getObsoleteStrict().parse(helems, origin);
+                return obsoleteStrict.parse(helems, origin);
             }
         }
     }
@@ -147,12 +129,12 @@ public class BestMatchSpec implements Co
         Args.notNull(origin, "Cookie origin");
         if (cookie.getVersion() > 0) {
             if (cookie instanceof SetCookie2) {
-                getStrict().validate(cookie, origin);
+                strict.validate(cookie, origin);
             } else {
-                getObsoleteStrict().validate(cookie, origin);
+                obsoleteStrict.validate(cookie, origin);
             }
         } else {
-            getNetscapeCompat().validate(cookie, origin);
+            netscapeDraft.validate(cookie, origin);
         }
     }
 
@@ -162,12 +144,12 @@ public class BestMatchSpec implements Co
         Args.notNull(origin, "Cookie origin");
         if (cookie.getVersion() > 0) {
             if (cookie instanceof SetCookie2) {
-                return getStrict().match(cookie, origin);
+                return strict.match(cookie, origin);
             } else {
-                return getObsoleteStrict().match(cookie, origin);
+                return obsoleteStrict.match(cookie, origin);
             }
         } else {
-            return getNetscapeCompat().match(cookie, origin);
+            return netscapeDraft.match(cookie, origin);
         }
     }
 
@@ -186,23 +168,23 @@ public class BestMatchSpec implements Co
         }
         if (version > 0) {
             if (isSetCookie2) {
-                return getStrict().formatCookies(cookies);
+                return strict.formatCookies(cookies);
             } else {
-                return getObsoleteStrict().formatCookies(cookies);
+                return obsoleteStrict.formatCookies(cookies);
             }
         } else {
-            return getNetscapeCompat().formatCookies(cookies);
+            return netscapeDraft.formatCookies(cookies);
         }
     }
 
     @Override
     public int getVersion() {
-        return getStrict().getVersion();
+        return strict.getVersion();
     }
 
     @Override
     public Header getVersionHeader() {
-        return getStrict().getVersionHeader();
+        return strict.getVersionHeader();
     }
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java Tue Aug 26 14:37:36 2014
@@ -36,9 +36,8 @@ import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.client.utils.DateUtils;
-import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
@@ -60,7 +59,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-@NotThreadSafe // superclass is @NotThreadSafe
+@ThreadSafe
 public class BrowserCompatSpec extends CookieSpecBase {
 
 
@@ -81,40 +80,21 @@ public class BrowserCompatSpec extends C
         "EEE, dd-MM-yyyy HH:mm:ss z",
     };
 
-    private final String[] datepatterns;
-
     /** Default constructor */
     public BrowserCompatSpec(final String[] datepatterns, final BrowserCompatSpecFactory.SecurityLevel securityLevel) {
-        super();
-        if (datepatterns != null) {
-            this.datepatterns = datepatterns.clone();
-        } else {
-            this.datepatterns = DEFAULT_DATE_PATTERNS;
-        }
-        switch (securityLevel) {
-            case SECURITYLEVEL_DEFAULT:
-                registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
-                break;
-            case SECURITYLEVEL_IE_MEDIUM:
-                registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler() {
-                        @Override
-                        public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException {
-                            // No validation
-                        }
-                    }
-                );
-                break;
-            default:
-                throw new RuntimeException("Unknown security level");
-        }
-
-        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new BasicDomainHandler());
-        registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
-        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
-        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
-        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
-                this.datepatterns));
-        registerAttribHandler(ClientCookie.VERSION_ATTR, new BrowserCompatVersionAttributeHandler());
+        super(new BrowserCompatVersionAttributeHandler(),
+                new BasicDomainHandler(),
+                securityLevel == BrowserCompatSpecFactory.SecurityLevel.SECURITYLEVEL_IE_MEDIUM ?
+                        new BasicPathHandler() {
+                            @Override
+                            public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException {
+                                // No validation
+                            }
+                        } : new BasicPathHandler(),
+                new BasicMaxAgeHandler(),
+                new BasicSecureHandler(),
+                new BasicCommentHandler(),
+                new BasicExpiresHandler(datepatterns != null ? datepatterns.clone() : DEFAULT_DATE_PATTERNS));
     }
 
     /** Default constructor */

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -28,6 +28,8 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.Args;
@@ -39,7 +41,7 @@ import org.apache.http.util.Args;
  */
 @Immutable
 public class BrowserCompatVersionAttributeHandler extends
-        AbstractCookieAttributeHandler {
+        AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     public BrowserCompatVersionAttributeHandler() {
         super();
@@ -64,4 +66,9 @@ public class BrowserCompatVersionAttribu
         cookie.setVersion(version);
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.VERSION_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java Tue Aug 26 14:37:36 2014
@@ -28,12 +28,14 @@
 package org.apache.http.impl.cookie;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
@@ -43,12 +45,29 @@ import org.apache.http.util.Args;
 /**
  * Cookie management functions shared by all specification.
  *
- *
  * @since 4.0
  */
-@NotThreadSafe // AbstractCookieSpec is not thread-safe
+@ThreadSafe
 public abstract class CookieSpecBase extends AbstractCookieSpec {
 
+    public CookieSpecBase() {
+        super();
+    }
+
+    /**
+     * @since 4.4
+     */
+    protected CookieSpecBase(final HashMap<String, CookieAttributeHandler> map) {
+        super(map);
+    }
+
+    /**
+     * @since 4.4
+     */
+    protected CookieSpecBase(final CommonCookieAttributeHandler... handlers) {
+        super(handlers);
+    }
+
     protected static String getDefaultPath(final CookieOrigin origin) {
         String defaultPath = origin.getPath();
         int lastSlashIndex = defaultPath.lastIndexOf('/');

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java Tue Aug 26 14:37:36 2014
@@ -31,7 +31,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.http.Header;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
@@ -41,7 +41,7 @@ import org.apache.http.cookie.MalformedC
  *
  * @since 4.1
  */
-@NotThreadSafe // superclass is @NotThreadSafe
+@ThreadSafe
 public class IgnoreSpec extends CookieSpecBase {
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java Tue Aug 26 14:37:36 2014
@@ -33,8 +33,8 @@ import java.util.List;
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.cookie.ClientCookie;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
@@ -52,35 +52,27 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-@NotThreadSafe // superclass is @NotThreadSafe
+@ThreadSafe
 public class NetscapeDraftSpec extends CookieSpecBase {
 
     protected static final String EXPIRES_PATTERN = "EEE, dd-MMM-yy HH:mm:ss z";
 
-    private final String[] datepatterns;
-
-    NetscapeDraftSpec(final boolean strictDomainValidation, final String[] datepatterns) {
-        super();
-        if (datepatterns != null) {
-            this.datepatterns = datepatterns.clone();
-        } else {
-            this.datepatterns = new String[] { EXPIRES_PATTERN };
-        }
-        registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
-        registerAttribHandler(ClientCookie.DOMAIN_ATTR,
-                strictDomainValidation ? new NetscapeDomainHandler() : new BasicDomainHandler());
-        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
-        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
-        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
-                this.datepatterns));
+    /** Default constructor */
+    public NetscapeDraftSpec(final String[] datepatterns) {
+        super(new BasicPathHandler(),
+                new NetscapeDomainHandler(),
+                new BasicSecureHandler(),
+                new BasicCommentHandler(),
+                new BasicExpiresHandler(
+                        datepatterns != null ? datepatterns.clone() : new String[]{EXPIRES_PATTERN}));
     }
 
-    public NetscapeDraftSpec(final String[] datepatterns) {
-        this(true, datepatterns);
+    NetscapeDraftSpec(final CommonCookieAttributeHandler... handlers) {
+        super(handlers);
     }
 
     public NetscapeDraftSpec() {
-        this(null);
+        this((String[]) null);
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java Tue Aug 26 14:37:36 2014
@@ -77,6 +77,10 @@ public class NetscapeDraftSpecFactory im
 
     @Override
     public CookieSpec create(final HttpContext context) {
+
+
+
+
         return new NetscapeDraftSpec(this.datepatterns);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java Tue Aug 26 14:37:36 2014
@@ -29,8 +29,9 @@ package org.apache.http.impl.cookie;
 import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -42,7 +43,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class RFC2109DomainHandler implements CookieAttributeHandler {
+public class RFC2109DomainHandler implements CommonCookieAttributeHandler {
 
     public RFC2109DomainHandler() {
         super();
@@ -120,4 +121,9 @@ public class RFC2109DomainHandler implem
         return host.equals(domain) || (domain.startsWith(".") && host.endsWith(domain));
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.DOMAIN_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java Tue Aug 26 14:37:36 2014
@@ -33,9 +33,10 @@ import java.util.List;
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.client.utils.DateUtils;
 import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookiePathComparator;
@@ -55,37 +56,30 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-@NotThreadSafe // superclass is @NotThreadSafe
+@ThreadSafe
 public class RFC2109Spec extends CookieSpecBase {
 
     private final static CookiePathComparator PATH_COMPARATOR = new CookiePathComparator();
 
-    private final static String[] DATE_PATTERNS = {
+    final static String[] DATE_PATTERNS = {
         DateUtils.PATTERN_RFC1123,
         DateUtils.PATTERN_RFC1036,
         DateUtils.PATTERN_ASCTIME
     };
 
-    private final String[] datepatterns;
     private final boolean oneHeader;
 
     /** Default constructor */
     public RFC2109Spec(final String[] datepatterns, final boolean oneHeader) {
-        super();
-        if (datepatterns != null) {
-            this.datepatterns = datepatterns.clone();
-        } else {
-            this.datepatterns = DATE_PATTERNS;
-        }
+        super(new RFC2109VersionHandler(),
+                new BasicPathHandler(),
+                new RFC2109DomainHandler(),
+                new BasicMaxAgeHandler(),
+                new BasicSecureHandler(),
+                new BasicCommentHandler(),
+                new BasicExpiresHandler(
+                        datepatterns != null ? datepatterns.clone() : DATE_PATTERNS));
         this.oneHeader = oneHeader;
-        registerAttribHandler(ClientCookie.VERSION_ATTR, new RFC2109VersionHandler());
-        registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
-        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new RFC2109DomainHandler());
-        registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
-        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
-        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
-        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
-                this.datepatterns));
     }
 
     /** Default constructor */
@@ -93,6 +87,12 @@ public class RFC2109Spec extends CookieS
         this(null, false);
     }
 
+    protected RFC2109Spec(final boolean oneHeader,
+                          final CommonCookieAttributeHandler... handlers) {
+        super(handlers);
+        this.oneHeader = oneHeader;
+    }
+
     @Override
     public List<Cookie> parse(final Header header, final CookieOrigin origin)
             throws MalformedCookieException {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java Tue Aug 26 14:37:36 2014
@@ -27,6 +27,8 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
@@ -39,7 +41,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class RFC2109VersionHandler extends AbstractCookieAttributeHandler {
+public class RFC2109VersionHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
 
     public RFC2109VersionHandler() {
         super();
@@ -72,4 +74,9 @@ public class RFC2109VersionHandler exten
         }
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.VERSION_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -28,8 +28,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
@@ -41,7 +42,7 @@ import org.apache.http.cookie.SetCookie2
  * @since 4.0
  */
 @Immutable
-public class RFC2965CommentUrlAttributeHandler implements CookieAttributeHandler {
+public class RFC2965CommentUrlAttributeHandler implements CommonCookieAttributeHandler {
 
       public RFC2965CommentUrlAttributeHandler() {
           super();
@@ -66,4 +67,9 @@ public class RFC2965CommentUrlAttributeH
           return true;
       }
 
-  }
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.COMMENTURL_ATTR;
+    }
+
+}

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -28,8 +28,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
@@ -41,7 +42,7 @@ import org.apache.http.cookie.SetCookie2
  * @since 4.0
  */
 @Immutable
-public class RFC2965DiscardAttributeHandler implements CookieAttributeHandler {
+public class RFC2965DiscardAttributeHandler implements CommonCookieAttributeHandler {
 
       public RFC2965DiscardAttributeHandler() {
           super();
@@ -66,4 +67,9 @@ public class RFC2965DiscardAttributeHand
           return true;
       }
 
-  }
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.DISCARD_ATTR;
+    }
+
+}

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -31,8 +31,8 @@ import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
 import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -46,7 +46,7 @@ import org.apache.http.util.Args;
  * @since 3.1
  */
 @Immutable
-public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
+public class RFC2965DomainAttributeHandler implements CommonCookieAttributeHandler {
 
     public RFC2965DomainAttributeHandler() {
         super();
@@ -186,4 +186,9 @@ public class RFC2965DomainAttributeHandl
         return effectiveHostWithoutDomain.indexOf('.') == -1;
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.DOMAIN_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -31,8 +31,8 @@ import java.util.StringTokenizer;
 
 import org.apache.http.annotation.Immutable;
 import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -46,7 +46,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class RFC2965PortAttributeHandler implements CookieAttributeHandler {
+public class RFC2965PortAttributeHandler implements CommonCookieAttributeHandler {
 
     public RFC2965PortAttributeHandler() {
         super();
@@ -160,4 +160,9 @@ public class RFC2965PortAttributeHandler
         return true;
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.PORT_ATTR;
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java Tue Aug 26 14:37:36 2014
@@ -35,7 +35,7 @@ import java.util.Map;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
@@ -51,7 +51,7 @@ import org.apache.http.util.CharArrayBuf
  *
  * @since 4.0
  */
-@NotThreadSafe // superclass is @NotThreadSafe
+@ThreadSafe
 public class RFC2965Spec extends RFC2109Spec {
 
     /**
@@ -63,12 +63,18 @@ public class RFC2965Spec extends RFC2109
     }
 
     public RFC2965Spec(final String[] datepatterns, final boolean oneHeader) {
-        super(datepatterns, oneHeader);
-        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new RFC2965DomainAttributeHandler());
-        registerAttribHandler(ClientCookie.PORT_ATTR, new RFC2965PortAttributeHandler());
-        registerAttribHandler(ClientCookie.COMMENTURL_ATTR, new RFC2965CommentUrlAttributeHandler());
-        registerAttribHandler(ClientCookie.DISCARD_ATTR, new RFC2965DiscardAttributeHandler());
-        registerAttribHandler(ClientCookie.VERSION_ATTR, new RFC2965VersionAttributeHandler());
+        super(oneHeader,
+                new RFC2965VersionAttributeHandler(),
+                new BasicPathHandler(),
+                new RFC2965DomainAttributeHandler(),
+                new RFC2965PortAttributeHandler(),
+                new BasicMaxAgeHandler(),
+                new BasicSecureHandler(),
+                new BasicCommentHandler(),
+                new BasicExpiresHandler(
+                        datepatterns != null ? datepatterns.clone() : DATE_PATTERNS),
+                new RFC2965CommentUrlAttributeHandler(),
+                new RFC2965DiscardAttributeHandler());
     }
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java?rev=1620612&r1=1620611&r2=1620612&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java Tue Aug 26 14:37:36 2014
@@ -29,8 +29,8 @@ package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
 import org.apache.http.cookie.ClientCookie;
+import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
@@ -44,7 +44,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @Immutable
-public class RFC2965VersionAttributeHandler implements CookieAttributeHandler {
+public class RFC2965VersionAttributeHandler implements CommonCookieAttributeHandler {
 
     public RFC2965VersionAttributeHandler() {
         super();
@@ -94,4 +94,9 @@ public class RFC2965VersionAttributeHand
         return true;
     }
 
+    @Override
+    public String getAttributeName() {
+        return ClientCookie.VERSION_ATTR;
+    }
+
 }



Mime
View raw message