summaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-04-03 15:34:05 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-04-04 11:00:20 +0200
commitaa596b7db316977de15052510201e17eb83e4089 (patch)
tree50c37def563700fbd0a1c1a3de674b4d049719b4 /jdisc_core
parentea56eae3f73af014d90956a96c719b94efc7ed5a (diff)
Make context() thread-safe
The context map is typically used to pass information between handler and filter chains. Filters and handlers are usually running on separate thread-pools.
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/Request.java7
1 files changed, 2 insertions, 5 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
index 061d803b978..466e74202c1 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
@@ -12,6 +12,7 @@ import com.yahoo.jdisc.service.CurrentContainer;
import com.yahoo.jdisc.service.ServerProvider;
import java.net.URI;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -35,7 +36,7 @@ import java.util.concurrent.TimeUnit;
*/
public class Request extends AbstractResource {
- private final Map<String, Object> context = new HashMap<>();
+ private final Map<String, Object> context = Collections.synchronizedMap(new HashMap<>());
private final HeaderFields headers = new HeaderFields();
private final Container container;
private final Request parent;
@@ -205,10 +206,6 @@ public class Request extends AbstractResource {
* <p>Returns the named application context objects. This data is not intended for network transport, rather they
* are intended for passing shared data between components of an Application.</p>
*
- * <p>Modifying the context map is a thread-unsafe operation -- any changes made after calling {@link
- * #connect(ResponseHandler)} might never become visible to other threads, and might throw
- * ConcurrentModificationExceptions in other threads.</p>
- *
* @return The context map.
*/
public Map<String, Object> context() {