Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6629

ConcurrentModificationException at AbstractResourceInfo.clearProxies()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.0.7, 3.1.4
    • Component/s: JAX-RS
    • Environment:

      Redhat Enterprise Linux 6, Java 8, Tomcat 8
      cxf-rt-frontend-jaxrs 3.1.2
      cxf-rt-rs-client 3.1.2

    • Estimated Complexity:
      Unknown

      Description

      Occasionally, concurrentmodification exception happens in AbstractResourceInfo. Following's a peek of stack trace

      java.util.ConcurrentModificationException at java.util.WeakHashMap$HashIterator.nextEntry(WeakHashMap.java:806) at java.util.WeakHashMap$ValueIterator.next(WeakHashMap.java:833) at org.apache.cxf.jaxrs.model.AbstractResourceInfo.clearProxies(AbstractResourceInfo.java:355) at org.apache.cxf.jaxrs.model.AbstractResourceInfo.clearThreadLocalProxies(AbstractResourceInfo.java:346) at org.apache.cxf.jaxrs.provider.ProviderFactory.clearProxies(ProviderFactory.java:745) at org.apache.cxf.jaxrs.provider.ProviderFactory.clearThreadLocalProxies(ProviderFactory.java:738) at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1195) at org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:1156) at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1092) at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:894) at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:865) at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:428) at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1621) at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1616) at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.get(WebClient.java:1536) at org.apache.cxf.jaxrs.client.spec.InvocationBuilderImpl.get(InvocationBuilderImpl.java:80) at 
      ...
      

      I noticed the codes around exception(AbstractResourceInfo:346) is as following (tlp.remove())

          private <T> void clearProxies(Map<Class<?>, Map<T, ThreadLocalProxy<?>>> tlps) {
              Map<T, ThreadLocalProxy<?>> proxies = tlps == null ? null : tlps.get(getServiceClass());
              if (proxies == null) {
                  return;
              }
              for (ThreadLocalProxy<?> tlp : proxies.values()) {
                  if (tlp != null) {
                      tlp.remove();
                  }
              }
          }
      

      I don't think it's good idea to remove threadlocal value while iterating the list.

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              violkim Chester Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: