hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1623733 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java-deprecated/org/apache/http/impl/cookie/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/cookie/ test/java/org/apache/http/client/protocol/
Date Tue, 09 Sep 2014 10:06:14 GMT
Author: olegk
Date: Tue Sep  9 10:06:14 2014
New Revision: 1623733

URL: http://svn.apache.org/r1623733
Log:
Initialize singleton cookie specs lazily

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
  (contents, props changed)
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
  (contents, props changed)
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
  (contents, props changed)
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
  (contents, props changed)
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java
      - copied, changed from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecFactory.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/RFC2109SpecFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecFactory.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
Tue Sep  9 10:06:14 2014
@@ -37,10 +37,12 @@ import org.apache.http.protocol.HttpCont
 /**
  * {@link CookieSpecProvider} implementation that ignores all cookies.
  *
+ * @deprecated (4.4) Use {@link org.apache.http.impl.cookie.IgnoreSpecProvider}.
+ *
  * @since 4.1
  */
 @Immutable
-@SuppressWarnings("deprecation")
+@Deprecated
 public class IgnoreSpecFactory implements CookieSpecFactory, CookieSpecProvider {
 
     public IgnoreSpecFactory() {

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
(from r1623462, 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-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
Tue Sep  9 10:06:14 2014
@@ -42,10 +42,12 @@ import org.apache.http.protocol.HttpCont
  * {@link org.apache.http.impl.cookie.NetscapeDraftSpec}. The instance returned by this factory
  * can be shared by multiple threads.
  *
+ * @deprecated (4.4) Use {@link org.apache.http.impl.cookie.NetscapeDraftSpecProvider}.
+ *
  * @since 4.0
  */
 @Immutable
-@SuppressWarnings("deprecation")
+@Deprecated
 public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecProvider {
 
     private final CookieSpec cookieSpec;

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
Tue Sep  9 10:06:14 2014
@@ -42,10 +42,12 @@ import org.apache.http.protocol.HttpCont
  * {@link org.apache.http.impl.cookie.RFC2109Spec}. The instance returned by this factory
  * can be shared by multiple threads.
  *
+ * @deprecated (4.4) Use {@link org.apache.http.impl.cookie.RFC2109SpecProvider}.
+ *
  * @since 4.0
  */
 @Immutable
-@SuppressWarnings("deprecation")
+@Deprecated
 public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider {
 
     private final CookieSpec cookieSpec;

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
Tue Sep  9 10:06:14 2014
@@ -42,10 +42,12 @@ import org.apache.http.protocol.HttpCont
  * {@link org.apache.http.impl.cookie.RFC2965Spec}. The instance returned by this factory
can
  * be shared by multiple threads.
  *
+ * @deprecated (4.4) Use {@link org.apache.http.impl.cookie.RFC2965SpecProvider}.
+ *
  * @since 4.0
  */
 @Immutable
-@SuppressWarnings("deprecation")
+@Deprecated
 public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider {
 
     private final CookieSpec cookieSpec;

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1623733&r1=1623732&r2=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
Tue Sep  9 10:06:14 2014
@@ -98,9 +98,9 @@ import org.apache.http.impl.conn.Default
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
 import org.apache.http.impl.cookie.DefaultCookieSpecProvider;
-import org.apache.http.impl.cookie.IgnoreSpecFactory;
-import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
-import org.apache.http.impl.cookie.RFC2965SpecFactory;
+import org.apache.http.impl.cookie.IgnoreSpecProvider;
+import org.apache.http.impl.cookie.NetscapeDraftSpecProvider;
+import org.apache.http.impl.cookie.RFC2965SpecProvider;
 import org.apache.http.impl.execchain.BackoffStrategyExec;
 import org.apache.http.impl.execchain.ClientExecChain;
 import org.apache.http.impl.execchain.MainClientExec;
@@ -1048,9 +1048,9 @@ public class HttpClientBuilder {
         if (cookieSpecRegistryCopy == null) {
             cookieSpecRegistryCopy = RegistryBuilder.<CookieSpecProvider>create()
                 .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
-                .register(CookieSpecs.STANDARD, new RFC2965SpecFactory())
-                .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
-                .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
+                .register(CookieSpecs.STANDARD, new RFC2965SpecProvider())
+                .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
+                .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider())
                 .build();
         }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java?rev=1623733&r1=1623732&r2=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
Tue Sep  9 10:06:14 2014
@@ -52,19 +52,22 @@ import org.apache.http.util.CharArrayBuf
 @ThreadSafe
 public class DefaultCookieSpec implements CookieSpec {
 
-    public enum CompatibilityLevel {
-        DEFAULT,
-        IE_MEDIUM_SECURITY
-    }
-
     private final RFC2965Spec strict;
     private final RFC2109Spec obsoleteStrict;
     private final NetscapeDraftSpec netscapeDraft;
 
+    DefaultCookieSpec(
+            final RFC2965Spec strict,
+            final RFC2109Spec obsoleteStrict,
+            final NetscapeDraftSpec netscapeDraft) {
+        this.strict = strict;
+        this.obsoleteStrict = obsoleteStrict;
+        this.netscapeDraft = netscapeDraft;
+    }
+
     public DefaultCookieSpec(
             final String[] datepatterns,
-            final boolean oneHeader,
-            final CompatibilityLevel compatibilityLevel) {
+            final boolean oneHeader) {
         super();
         this.strict = new RFC2965Spec(oneHeader,
                 new RFC2965VersionAttributeHandler(),
@@ -85,25 +88,13 @@ public class DefaultCookieSpec implement
                 new BasicCommentHandler());
         this.netscapeDraft = new NetscapeDraftSpec(
                 new BasicDomainHandler(),
-                compatibilityLevel == CompatibilityLevel.IE_MEDIUM_SECURITY ?
-                        new BasicPathHandler() {
-                            @Override
-                            public void validate(final Cookie cookie, final CookieOrigin
origin) throws MalformedCookieException {
-                                // No validation
-                            }
-                        } : new BasicPathHandler(),
+                new BasicPathHandler(),
                 new BasicSecureHandler(),
                 new BasicCommentHandler(),
                 new BasicExpiresHandler(
                         datepatterns != null ? datepatterns.clone() : new String[]{NetscapeDraftSpec.EXPIRES_PATTERN}));
     }
 
-    public DefaultCookieSpec(
-            final String[] datepatterns,
-            final boolean oneHeader) {
-        this(datepatterns, oneHeader, null);
-    }
-
     public DefaultCookieSpec() {
         this(null, false);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java?rev=1623733&r1=1623732&r2=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
Tue Sep  9 10:06:14 2014
@@ -28,8 +28,11 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
 import org.apache.http.cookie.CookieSpecProvider;
+import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.protocol.HttpContext;
 
 /**
@@ -42,19 +45,72 @@ import org.apache.http.protocol.HttpCont
 @Immutable
 public class DefaultCookieSpecProvider implements CookieSpecProvider {
 
-    private final CookieSpec cookieSpec;
+    public enum CompatibilityLevel {
+        DEFAULT,
+        IE_MEDIUM_SECURITY
+    }
 
-    public DefaultCookieSpecProvider(final String[] datepatterns, final boolean oneHeader)
{
+    private final CompatibilityLevel compatibilityLevel;
+    private final String[] datepatterns;
+    private final boolean oneHeader;
+
+    private volatile CookieSpec cookieSpec;
+
+    public DefaultCookieSpecProvider(
+            final CompatibilityLevel compatibilityLevel,
+            final String[] datepatterns,
+            final boolean oneHeader) {
         super();
-        this.cookieSpec = new DefaultCookieSpec(datepatterns, oneHeader);;
+        this.compatibilityLevel = compatibilityLevel != null ? compatibilityLevel : CompatibilityLevel.DEFAULT;
+        this.datepatterns = datepatterns;
+        this.oneHeader = oneHeader;
     }
 
     public DefaultCookieSpecProvider() {
-        this(null, false);
+        this(CompatibilityLevel.DEFAULT, null, false);
     }
 
     @Override
     public CookieSpec create(final HttpContext context) {
+        if (cookieSpec == null) {
+            synchronized (this) {
+                if (cookieSpec == null) {
+                    final RFC2965Spec strict = new RFC2965Spec(this.oneHeader,
+                            new RFC2965VersionAttributeHandler(),
+                            new BasicPathHandler(),
+                            new RFC2965DomainAttributeHandler(),
+                            new RFC2965PortAttributeHandler(),
+                            new BasicMaxAgeHandler(),
+                            new BasicSecureHandler(),
+                            new BasicCommentHandler(),
+                            new RFC2965CommentUrlAttributeHandler(),
+                            new RFC2965DiscardAttributeHandler());
+                    final RFC2109Spec obsoleteStrict = new RFC2109Spec(this.oneHeader,
+                            new RFC2109VersionHandler(),
+                            new BasicPathHandler(),
+                            new RFC2109DomainHandler(),
+                            new BasicMaxAgeHandler(),
+                            new BasicSecureHandler(),
+                            new BasicCommentHandler());
+                    final NetscapeDraftSpec netscapeDraft = new NetscapeDraftSpec(
+                            new BasicDomainHandler(),
+                            this.compatibilityLevel == CompatibilityLevel.IE_MEDIUM_SECURITY
?
+                                    new BasicPathHandler() {
+                                        @Override
+                                        public void validate(
+                                                final Cookie cookie,
+                                                final CookieOrigin origin) throws MalformedCookieException
{
+                                            // No validation
+                                        }
+                                    } : new BasicPathHandler(),
+                            new BasicSecureHandler(),
+                            new BasicCommentHandler(),
+                            new BasicExpiresHandler(this.datepatterns != null ? this.datepatterns.clone()
:
+                                    new String[]{NetscapeDraftSpec.EXPIRES_PATTERN}));
+                    this.cookieSpec = new DefaultCookieSpec(strict, obsoleteStrict, netscapeDraft);
+                }
+            }
+        }
         return this.cookieSpec;
     }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
Tue Sep  9 10:06:14 2014
@@ -33,28 +33,28 @@ import org.apache.http.cookie.CookieSpec
 import org.apache.http.protocol.HttpContext;
 
 /**
- * {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance
of
- * {@link BestMatchSpec}. The instance returned by this factory can
- * be shared by multiple threads.
+ * {@link org.apache.http.cookie.CookieSpecProvider} implementation that ignores all cookies.
  *
  * @since 4.4
  */
 @Immutable
-public class DefaultCookieSpecProvider implements CookieSpecProvider {
+public class IgnoreSpecProvider implements CookieSpecProvider {
 
-    private final CookieSpec cookieSpec;
+    private volatile CookieSpec cookieSpec;
 
-    public DefaultCookieSpecProvider(final String[] datepatterns, final boolean oneHeader)
{
+    public IgnoreSpecProvider() {
         super();
-        this.cookieSpec = new DefaultCookieSpec(datepatterns, oneHeader);;
-    }
-
-    public DefaultCookieSpecProvider() {
-        this(null, false);
     }
 
     @Override
     public CookieSpec create(final HttpContext context) {
+        if (cookieSpec == null) {
+            synchronized (this) {
+                if (cookieSpec == null) {
+                    this.cookieSpec = new IgnoreSpec();
+                }
+            }
+        }
         return this.cookieSpec;
     }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
Tue Sep  9 10:06:14 2014
@@ -34,27 +34,36 @@ import org.apache.http.protocol.HttpCont
 
 /**
  * {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance
of
- * {@link BestMatchSpec}. The instance returned by this factory can
- * be shared by multiple threads.
+ * {@link NetscapeDraftSpec}. The instance returned by this factory
+ * can be shared by multiple threads.
  *
  * @since 4.4
  */
 @Immutable
-public class DefaultCookieSpecProvider implements CookieSpecProvider {
+public class NetscapeDraftSpecProvider implements CookieSpecProvider {
 
-    private final CookieSpec cookieSpec;
+    private final String[] datepatterns;
 
-    public DefaultCookieSpecProvider(final String[] datepatterns, final boolean oneHeader)
{
+    private volatile CookieSpec cookieSpec;
+
+    public NetscapeDraftSpecProvider(final String[] datepatterns) {
         super();
-        this.cookieSpec = new DefaultCookieSpec(datepatterns, oneHeader);;
+        this.datepatterns = datepatterns;
     }
 
-    public DefaultCookieSpecProvider() {
-        this(null, false);
+    public NetscapeDraftSpecProvider() {
+        this(null);
     }
 
     @Override
     public CookieSpec create(final HttpContext context) {
+        if (cookieSpec == null) {
+            synchronized (this) {
+                if (cookieSpec == null) {
+                    this.cookieSpec = new NetscapeDraftSpec(this.datepatterns);
+                }
+            }
+        }
         return this.cookieSpec;
     }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java
Tue Sep  9 10:06:14 2014
@@ -34,27 +34,36 @@ import org.apache.http.protocol.HttpCont
 
 /**
  * {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance
of
- * {@link BestMatchSpec}. The instance returned by this factory can
- * be shared by multiple threads.
+ * {@link RFC2109Spec}. The instance returned by this factory
+ * can be shared by multiple threads.
  *
  * @since 4.4
  */
 @Immutable
-public class DefaultCookieSpecProvider implements CookieSpecProvider {
+public class RFC2109SpecProvider implements CookieSpecProvider {
 
-    private final CookieSpec cookieSpec;
+    private final boolean oneHeader;
 
-    public DefaultCookieSpecProvider(final String[] datepatterns, final boolean oneHeader)
{
+    private volatile CookieSpec cookieSpec;
+
+    public RFC2109SpecProvider(final boolean oneHeader) {
         super();
-        this.cookieSpec = new DefaultCookieSpec(datepatterns, oneHeader);;
+        this.oneHeader = oneHeader;
     }
 
-    public DefaultCookieSpecProvider() {
-        this(null, false);
+    public RFC2109SpecProvider() {
+        this(false);
     }
 
     @Override
     public CookieSpec create(final HttpContext context) {
+        if (cookieSpec == null) {
+            synchronized (this) {
+                if (cookieSpec == null) {
+                    this.cookieSpec = new RFC2109Spec(null, this.oneHeader);
+                }
+            }
+        }
         return this.cookieSpec;
     }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java
(from r1623462, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java&r1=1623462&r2=1623733&rev=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java
Tue Sep  9 10:06:14 2014
@@ -34,27 +34,36 @@ import org.apache.http.protocol.HttpCont
 
 /**
  * {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance
of
- * {@link BestMatchSpec}. The instance returned by this factory can
+ * {@link RFC2965Spec}. The instance returned by this factory can
  * be shared by multiple threads.
  *
  * @since 4.4
  */
 @Immutable
-public class DefaultCookieSpecProvider implements CookieSpecProvider {
+public class RFC2965SpecProvider implements CookieSpecProvider {
 
-    private final CookieSpec cookieSpec;
+    private final boolean oneHeader;
 
-    public DefaultCookieSpecProvider(final String[] datepatterns, final boolean oneHeader)
{
+    private volatile CookieSpec cookieSpec;
+
+    public RFC2965SpecProvider(final boolean oneHeader) {
         super();
-        this.cookieSpec = new DefaultCookieSpec(datepatterns, oneHeader);;
+        this.oneHeader = oneHeader;
     }
 
-    public DefaultCookieSpecProvider() {
-        this(null, false);
+    public RFC2965SpecProvider() {
+        this(false);
     }
 
     @Override
     public CookieSpec create(final HttpContext context) {
+        if (cookieSpec == null) {
+            synchronized (this) {
+                if (cookieSpec == null) {
+                    this.cookieSpec = new RFC2965Spec(null, this.oneHeader);
+                }
+            }
+        }
         return this.cookieSpec;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java?rev=1623733&r1=1623732&r2=1623733&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
Tue Sep  9 10:06:14 2014
@@ -48,10 +48,10 @@ import org.apache.http.impl.client.Basic
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.apache.http.impl.cookie.BasicClientCookie2;
 import org.apache.http.impl.cookie.DefaultCookieSpecProvider;
-import org.apache.http.impl.cookie.IgnoreSpecFactory;
+import org.apache.http.impl.cookie.IgnoreSpecProvider;
 import org.apache.http.impl.cookie.NetscapeDraftSpec;
-import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
-import org.apache.http.impl.cookie.RFC2965SpecFactory;
+import org.apache.http.impl.cookie.NetscapeDraftSpecProvider;
+import org.apache.http.impl.cookie.RFC2965SpecProvider;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.protocol.HttpCoreContext;
 import org.junit.Assert;
@@ -81,9 +81,9 @@ public class TestRequestAddCookies {
 
         this.cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
             .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
-            .register(CookieSpecs.STANDARD, new RFC2965SpecFactory())
-            .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
-            .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
+            .register(CookieSpecs.STANDARD, new RFC2965SpecProvider())
+            .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
+            .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider())
             .build();
     }
 



Mime
View raw message