From d2a63269e513ca846f95aa40207f57f325187998 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 19 Mar 2009 02:00:15 +0000 Subject: [PATCH] Make code thread-safe by using dirty as a volatile guard git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@755811 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/http/entity/mime/MultipartEntity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java index 56c3eb85a..c5c50d4a6 100644 --- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java +++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java @@ -39,6 +39,8 @@ import java.util.Iterator; import java.util.List; import java.util.Random; +import net.jcip.annotations.ThreadSafe; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.entity.mime.content.ContentBody; @@ -54,6 +56,7 @@ import org.apache.james.mime4j.message.Message; * * @since 4.0 */ +@ThreadSafe public class MultipartEntity implements HttpEntity { /** @@ -68,7 +71,7 @@ public class MultipartEntity implements HttpEntity { private final Header contentType; private long length; - private boolean dirty; + private volatile boolean dirty; // used to decide whether to recalculate length public MultipartEntity( HttpMultipartMode mode,