No need for response context to not be static
@@ -277,7 +277,7 @@ public class ClientImpl
public Map<String, Object> getResponseContext() {
if (!responseContext.containsKey(Thread.currentThread())) {
final Thread t = Thread.currentThread();
- responseContext.put(t, new ResponseContext());
+ responseContext.put(t, new ResponseContext(responseContext));
}
return responseContext.get(Thread.currentThread());
}
@@ -287,7 +287,7 @@ public class ClientImpl
responseContext.put(Thread.currentThread(), c);
return c;
}
- ResponseContext c = new ResponseContext(ctx);
+ ResponseContext c = new ResponseContext(ctx, responseContext);
responseContext.put(Thread.currentThread(), c);
return c;
}
@@ -476,7 +476,7 @@ public class ClientImpl
context.put(REQUEST_CONTEXT, reqContext);
}
if (resContext == null) {
- resContext = new ResponseContext();
+ resContext = new ResponseContext(responseContext);
context.put(RESPONSE_CONTEXT, resContext);
}
@@ -1083,16 +1083,19 @@ public class ClientImpl
* Class to handle the response contexts. The clear is overloaded to remove
* this context from the threadLocal caches in the ClientImpl
*/
- class ResponseContext implements Map<String, Object>, Serializable {
+ static class ResponseContext implements Map<String, Object>, Serializable {
private static final long serialVersionUID = 2L;
final Map<String, Object> wrapped;
+ final Map<Thread, ResponseContext> responseContext;
- ResponseContext(Map<String, Object> origMap) {
+ ResponseContext(Map<String, Object> origMap, Map<Thread, ResponseContext> rc) {
wrapped = origMap;
+ responseContext = rc;
}
- ResponseContext() {
+ ResponseContext(Map<Thread, ResponseContext> rc) {
wrapped = new HashMap<>();
+ responseContext = rc;
}
@Override
