You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2020/05/29 08:46:50 UTC

[cxf] 02/02: CXF-8290 - Don't lock by default in org.apache.cxf.jaxrs.model.AbstractResourceInfo#getProxyMap

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch CXF-8290
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 4ef74e06bf332d474847a8d1e49139a434605c7c
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri May 29 09:46:19 2020 +0100

    CXF-8290 - Don't lock by default in org.apache.cxf.jaxrs.model.AbstractResourceInfo#getProxyMap
---
 .../main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
index 106aea6..595e0c8 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
@@ -177,6 +177,13 @@ public abstract class AbstractResourceInfo {
 
     @SuppressWarnings("unchecked")
     private <T> Map<Class<?>, Map<T, ThreadLocalProxy<?>>> getProxyMap(String prop, boolean create) {
+        // Avoid synchronizing on the bus for a ConcurrentHashMAp
+        if (bus.getProperties() instanceof ConcurrentHashMap) {
+            return (Map<Class<?>, Map<T, ThreadLocalProxy<?>>>) bus.getProperties().computeIfAbsent(prop, k ->
+                new ConcurrentHashMap<Class<?>, Map<T, ThreadLocalProxy<?>>>(2)
+            );
+        }
+
         Object property = null;
         synchronized (bus) {
             property = bus.getProperty(prop);