Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-441

Client proxies produced by RestClientProxyFactoryBean (Spring) are not thread safe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 2.0.GA
    • None
    • Workaround Exists
    • Hide

      Here is a workaround for those who are struggling with this problem:
      <bean id="restHttpClient" class="org.apache.commons.httpclient.HttpClient" scope="prototype">
      <constructor-arg>
      <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager" p:maxConnectionsPerHost="10" />
      </constructor-arg>
      </bean>

      <bean id="treeProviderService" class="org.jboss.resteasy.client.spring.RestClientProxyFactoryBean"
      p:serviceInterface="com.example.TreeProviderService"
      p:baseUri="${server.url}"
      p:httpClient-ref="restHttpClient" />

      Show
      Here is a workaround for those who are struggling with this problem: <bean id="restHttpClient" class="org.apache.commons.httpclient.HttpClient" scope="prototype"> <constructor-arg> <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager" p:maxConnectionsPerHost="10" /> </constructor-arg> </bean> <bean id="treeProviderService" class="org.jboss.resteasy.client.spring.RestClientProxyFactoryBean" p:serviceInterface="com.example.TreeProviderService" p:baseUri="${server.url}" p:httpClient-ref="restHttpClient" />

    Description

      The RestClientProxyFactoryBean used in Spring environment produces singletons that are not thread safe (RestClientProxyFactoryBean returns true in isSingleton() method).

      • This results in multiple threads accessing single apache's HttpClient which is not thread safe by default
      • The threads that simultaneously use single RestEasy proxy instance freeze

      The fix is really simple as described here: http://hc.apache.org/httpclient-3.x/threading.html

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            galet_jira Michal Galet (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: