You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by se...@apache.org on 2009/07/24 02:02:54 UTC

svn commit: r797269 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java

Author: sebb
Date: Fri Jul 24 00:02:54 2009
New Revision: 797269

URL: http://svn.apache.org/viewvc?rev=797269&view=rev
Log:
Add thread-safety annotations
Copy string array in constructor to avoid external changes

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java

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=797269&r1=797268&r2=797269&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 Fri Jul 24 00:02:54 2009
@@ -29,6 +29,8 @@
 
 import java.util.List;
 
+import net.jcip.annotations.NotThreadSafe;
+
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.cookie.Cookie;
@@ -44,19 +46,21 @@
  *
  * @since 4.0
  */
+@NotThreadSafe // CookieSpec fields are @NotThreadSafe
 public class BestMatchSpec implements CookieSpec {
 
     private final String[] datepatterns;
     private final boolean oneHeader;
     
-    private RFC2965Spec strict;
-    private RFC2109Spec obsoleteStrict;
-    private BrowserCompatSpec compat;
-    private NetscapeDraftSpec netscape;
+    // Cached values of CookieSpec instances
+    private RFC2965Spec strict; // @NotThreadSafe
+    private RFC2109Spec obsoleteStrict; // @NotThreadSafe
+    private BrowserCompatSpec compat; // @NotThreadSafe
+    private NetscapeDraftSpec netscape; // @NotThreadSafe
 
     public BestMatchSpec(final String[] datepatterns, boolean oneHeader) {
         super();
-        this.datepatterns = datepatterns;
+        this.datepatterns = datepatterns.clone();
         this.oneHeader = oneHeader;
     }