Skip to content

Concurrency issue using DefaultHttpFetcher: Invalid use of SingleClientConnManager #47

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?

Use ab to generate 2 (or more) concurrent post requests against the 
example-consumer application:
ab -n 2 -c 2 -p post_data -T 'application/x-www-form-urlencoded' 
http://localhost:8080/lso2/
where post_data contains the following:
openid=yourdomain.com&stage=discovery

What is the expected output? What do you see instead?

Caused by: java.lang.IllegalStateException: Invalid use of 
SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
    at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
    at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:356)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
    at com.google.step2.http.DefaultHttpFetcher.fetch(DefaultHttpFetcher.java:76)
    at com.google.step2.discovery.UrlHostMetaFetcher.getHostMeta(UrlHostMetaFetcher.java:58)


What version of the product are you using? On what operating system?
Latest snapshot

Please provide any additional information below.
The problem appears to stem from the use of DefaultHttpClient in the default 
fetcher. The httpclient docs indicate the DefaultHttpClient is threadsafe: 
http://hc.apache.org/httpcomponents-client-dev/tutorial/html/httpagent.html

However, other information suggests using ThreadSafeClientConnManager 
http://stackoverflow.com/questions/1281219/best-practice-to-use-httpclient-in-mu
ltithreaded-environment

Updating to the latest httpclient and httpcore libraries didn’t resolve the 
problem. Switching to ThreadSafeClientConnManager resolves the issue.  I have 
an HttpFetcher implementation which I can contribute.

Original issue reported on code.google.com by zestia.d...@gmail.com on 17 Apr 2011 at 7:49

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions