From f3fdcc1a066a9df07d5088203b8820981b5f46d5 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Wed, 18 Mar 2009 23:47:46 +0000 Subject: [PATCH] Document classes which are not thread-safe currently git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@755789 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/conn/params/ConnConnectionParamBean.java | 3 +++ .../org/apache/http/conn/params/ConnManagerParamBean.java | 3 +++ .../java/org/apache/http/conn/params/ConnPerRouteBean.java | 3 +++ .../org/apache/http/conn/params/ConnRouteParamBean.java | 3 +++ .../java/org/apache/http/conn/routing/RouteTracker.java | 3 +++ .../org/apache/http/impl/client/ClientParamsStack.java | 3 +++ .../apache/http/impl/client/DefaultRequestDirector.java | 5 ++++- .../http/impl/client/EntityEnclosingRequestWrapper.java | 3 +++ .../org/apache/http/impl/client/RedirectLocations.java | 3 +++ .../java/org/apache/http/impl/client/RequestWrapper.java | 3 +++ .../java/org/apache/http/impl/client/RoutedRequest.java | 7 +++++-- 11 files changed, 36 insertions(+), 3 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java index 5e53a86f9..902091425 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java @@ -31,6 +31,8 @@ package org.apache.http.conn.params; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@NotThreadSafe public class ConnConnectionParamBean extends HttpAbstractParamBean { public ConnConnectionParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java index 2b34f71f9..2d4eb2ac6 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java @@ -31,6 +31,8 @@ package org.apache.http.conn.params; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@NotThreadSafe public class ConnManagerParamBean extends HttpAbstractParamBean { public ConnManagerParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java index bb4fad3a6..a800566fd 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java @@ -33,6 +33,8 @@ package org.apache.http.conn.params; import java.util.HashMap; import java.util.Map; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.conn.routing.HttpRoute; /** @@ -46,6 +48,7 @@ import org.apache.http.conn.routing.HttpRoute; * * @since 4.0 */ +@NotThreadSafe // maxPerHostMap and defaultMax public final class ConnPerRouteBean implements ConnPerRoute { /** The default maximum number of connections allowed per host */ diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java index 34939e9fc..c2eaa85be 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java @@ -33,6 +33,8 @@ package org.apache.http.conn.params; import java.net.InetAddress; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.HttpHost; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpAbstractParamBean; @@ -45,6 +47,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@NotThreadSafe public class ConnRouteParamBean extends HttpAbstractParamBean { public ConnRouteParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java index ae02fbfc8..b3e8ffe39 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java @@ -33,6 +33,8 @@ package org.apache.http.conn.routing; import java.net.InetAddress; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.HttpHost; @@ -46,6 +48,7 @@ import org.apache.http.HttpHost; * * @since 4.0 */ +@NotThreadSafe public final class RouteTracker implements RouteInfo, Cloneable { /** The target host to connect to. */ diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java b/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java index 057c257ea..f1facb0fa 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java @@ -32,6 +32,8 @@ package org.apache.http.impl.client; +import net.jcip.annotations.NotThreadSafe; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.params.HttpParams; @@ -76,6 +78,7 @@ import org.apache.http.params.AbstractHttpParams; * * @since 4.0 */ +@NotThreadSafe public class ClientParamsStack extends AbstractHttpParams { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java index d5b666164..e29669dc7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java @@ -39,6 +39,8 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; +import net.jcip.annotations.NotThreadSafe; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.ConnectionReuseStrategy; @@ -103,6 +105,7 @@ import org.apache.http.protocol.HttpRequestExecutor; * * @since 4.0 */ +@NotThreadSafe // e.g. managedConn public class DefaultRequestDirector implements RequestDirector { private final Log log = LogFactory.getLog(getClass()); @@ -763,7 +766,7 @@ public class DefaultRequestDirector implements RequestDirector { } } - int status = response.getStatusLine().getStatusCode(); + int status = response.getStatusLine().getStatusCode(); // can't be null if (status > 299) { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java index f839538fb..2590441dc 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java @@ -31,6 +31,8 @@ package org.apache.http.impl.client; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -50,6 +52,7 @@ import org.apache.http.protocol.HTTP; * * @since 4.0 */ +@NotThreadSafe // e.g. [gs]etEntity() public class EntityEnclosingRequestWrapper extends RequestWrapper implements HttpEntityEnclosingRequest { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java index 0f5793042..ac235d61f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java @@ -35,11 +35,14 @@ import java.net.URI; import java.util.HashSet; import java.util.Set; +import net.jcip.annotations.NotThreadSafe; + /** * A collection of URIs that were used as redirects. * * @since 4.0 */ +@NotThreadSafe // HashSet is not synch. public class RedirectLocations { private final Set uris; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java index 15f0d07ca..4eeab6f4a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java @@ -34,6 +34,8 @@ package org.apache.http.impl.client; import java.net.URI; import java.net.URISyntaxException; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; @@ -56,6 +58,7 @@ import org.apache.http.params.HttpProtocolParams; * * @since 4.0 */ +@NotThreadSafe public class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest { private final HttpRequest original; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RoutedRequest.java b/httpclient/src/main/java/org/apache/http/impl/client/RoutedRequest.java index b9df1581b..afba33d32 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RoutedRequest.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RoutedRequest.java @@ -31,6 +31,8 @@ package org.apache.http.impl.client; +import net.jcip.annotations.NotThreadSafe; + import org.apache.http.conn.routing.HttpRoute; @@ -44,10 +46,11 @@ import org.apache.http.conn.routing.HttpRoute; * * @since 4.0 */ +@NotThreadSafe // RequestWrapper is @NotThreadSafe public class RoutedRequest { - protected final RequestWrapper request; - protected final HttpRoute route; + protected final RequestWrapper request; // @NotThreadSafe + protected final HttpRoute route; // @Immutable /** * Creates a new routed request.