Twitter4J

add max connections and shutdown for apache httpclient

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.1.9
  • Component/s: httpclient-support
  • Labels:
    None

Description

I added these in master on git://github.com/ericcj/twitter4j.git

Activity

Hide
Eric Jensen added a comment -
I realized this is actually fixing a more serious bug with using the httpclient implementation than I thought. The original version does not pass a ConnectionManager to the DefaultHttpClient constructor, which as per http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html results in using a SingleClientConnManager which is documented as "Even though this class is thread-safe it ought to be used by one execution thread only." even though twitter4j.Twitter is supposed to be safe for use with concurrent requests. Specifically, the behavior of SingleClientConnManager seems to be to force a close of any in-flight request if you make a concurrent one.
Show
Eric Jensen added a comment - I realized this is actually fixing a more serious bug with using the httpclient implementation than I thought. The original version does not pass a ConnectionManager to the DefaultHttpClient constructor, which as per http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html results in using a SingleClientConnManager which is documented as "Even though this class is thread-safe it ought to be used by one execution thread only." even though twitter4j.Twitter is supposed to be safe for use with concurrent requests. Specifically, the behavior of SingleClientConnManager seems to be to force a close of any in-flight request if you make a concurrent one.
Hide
Yusuke Yamamoto added a comment -
total connection is set at HttpClientImpl:89
        cm.setMaxTotal(conf.getHttpMaxTotalConnections());

and shutdown at :114
        client.getConnectionManager().shutdown();

Please reopen if you still see any issue.
Show
Yusuke Yamamoto added a comment - total connection is set at HttpClientImpl:89         cm.setMaxTotal(conf.getHttpMaxTotalConnections()); and shutdown at :114         client.getConnectionManager().shutdown(); Please reopen if you still see any issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: