You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Mohit Anchlia <mo...@gmail.com> on 2011/09/26 18:04:17 UTC

4.1.2 http client Thread in WAITING state on getEntryBlocking

I am using 4.1.2 and trying to figure out why my threads are all
waiting on this block. I have this code:

Can someone please help?

	static {
		cm.setMaxTotal(NO_CONN*2);
		cm.setDefaultMaxPerRoute(NO_CONN);
	}

	private static ThreadSafeClientConnManager cm = new
ThreadSafeClientConnManager();

	private static HttpClient httpclient = new DefaultHttpClient(cm);


			StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);

			httpput.setEntity(stringEntity);

			HttpResponse response = httpclient.execute(httpput);


"pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
on condition [0x00000000446f7000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000061d5866f0> (a
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
        at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
        at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
        at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
        at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
        at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
        at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
        at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)


jars in my classpath:


ls -ltr jars
total 1572
-rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
-rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
-rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
-rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
-rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
-rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
-rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
-rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
-rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
-rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking

Posted by Sam Crawford <sa...@gmail.com>.
Yes, absolutely.

Thanks,

Sam


On 26 September 2011 21:57, Mohit Anchlia <mo...@gmail.com> wrote:
> Thanks! should it be read on http errors too? for eg: http code 400, 500 etc.
>
> On Mon, Sep 26, 2011 at 1:43 PM, Sam Crawford <sa...@gmail.com> wrote:
>> That's correct. You have to consume the entity before the connection
>> is released. See the documentation (section 1.1.5) at
>> http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e72
>>
>>
>> On 26 September 2011 20:19, Mohit Anchlia <mo...@gmail.com> wrote:
>>> On Mon, Sep 26, 2011 at 12:06 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
>>>> On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote:
>>>>> I am using 4.1.2 and trying to figure out why my threads are all
>>>>> waiting on this block. I have this code:
>>>>>
>>>>
>>>> That's because your code is leaking connections.
>>>
>>> I just added this line and it resolved the issue.                                       \
>>> EntityUtils.toString(entity);
>>>
>>> Wondering if it's necessary to read from the entity otherwise it holds
>>> on to the connection.
>>>
>>>>
>>>> Oleg
>>>>
>>>>> Can someone please help?
>>>>>
>>>>>       static {
>>>>>               cm.setMaxTotal(NO_CONN*2);
>>>>>               cm.setDefaultMaxPerRoute(NO_CONN);
>>>>>       }
>>>>>
>>>>>       private static ThreadSafeClientConnManager cm = new
>>>>> ThreadSafeClientConnManager();
>>>>>
>>>>>       private static HttpClient httpclient = new DefaultHttpClient(cm);
>>>>>
>>>>>
>>>>>                       StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);
>>>>>
>>>>>                       httpput.setEntity(stringEntity);
>>>>>
>>>>>                       HttpResponse response = httpclient.execute(httpput);
>>>>>
>>>>>
>>>>> "pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
>>>>> on condition [0x00000000446f7000]
>>>>>    java.lang.Thread.State: WAITING (parking)
>>>>>         at sun.misc.Unsafe.park(Native Method)
>>>>>         - parking to wait for  <0x000000061d5866f0> (a
>>>>> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>>>>>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
>>>>>         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
>>>>>         at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
>>>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
>>>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
>>>>>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
>>>>>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
>>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>>>>         at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
>>>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
>>>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
>>>>>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>>>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>>>         at java.lang.Thread.run(Thread.java:662)
>>>>>
>>>>>
>>>>> jars in my classpath:
>>>>>
>>>>>
>>>>> ls -ltr jars
>>>>> total 1572
>>>>> -rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
>>>>> -rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
>>>>> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
>>>>> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
>>>>> -rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
>>>>> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
>>>>> -rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
>>>>> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
>>>>> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
>>>>> -rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking

Posted by Mohit Anchlia <mo...@gmail.com>.
Thanks! should it be read on http errors too? for eg: http code 400, 500 etc.

On Mon, Sep 26, 2011 at 1:43 PM, Sam Crawford <sa...@gmail.com> wrote:
> That's correct. You have to consume the entity before the connection
> is released. See the documentation (section 1.1.5) at
> http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e72
>
>
> On 26 September 2011 20:19, Mohit Anchlia <mo...@gmail.com> wrote:
>> On Mon, Sep 26, 2011 at 12:06 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
>>> On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote:
>>>> I am using 4.1.2 and trying to figure out why my threads are all
>>>> waiting on this block. I have this code:
>>>>
>>>
>>> That's because your code is leaking connections.
>>
>> I just added this line and it resolved the issue.                                       \
>> EntityUtils.toString(entity);
>>
>> Wondering if it's necessary to read from the entity otherwise it holds
>> on to the connection.
>>
>>>
>>> Oleg
>>>
>>>> Can someone please help?
>>>>
>>>>       static {
>>>>               cm.setMaxTotal(NO_CONN*2);
>>>>               cm.setDefaultMaxPerRoute(NO_CONN);
>>>>       }
>>>>
>>>>       private static ThreadSafeClientConnManager cm = new
>>>> ThreadSafeClientConnManager();
>>>>
>>>>       private static HttpClient httpclient = new DefaultHttpClient(cm);
>>>>
>>>>
>>>>                       StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);
>>>>
>>>>                       httpput.setEntity(stringEntity);
>>>>
>>>>                       HttpResponse response = httpclient.execute(httpput);
>>>>
>>>>
>>>> "pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
>>>> on condition [0x00000000446f7000]
>>>>    java.lang.Thread.State: WAITING (parking)
>>>>         at sun.misc.Unsafe.park(Native Method)
>>>>         - parking to wait for  <0x000000061d5866f0> (a
>>>> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>>>>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
>>>>         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
>>>>         at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
>>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
>>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
>>>>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
>>>>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>>>         at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
>>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
>>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
>>>>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>>         at java.lang.Thread.run(Thread.java:662)
>>>>
>>>>
>>>> jars in my classpath:
>>>>
>>>>
>>>> ls -ltr jars
>>>> total 1572
>>>> -rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
>>>> -rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
>>>> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
>>>> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
>>>> -rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
>>>> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
>>>> -rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
>>>> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
>>>> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
>>>> -rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking

Posted by Sam Crawford <sa...@gmail.com>.
That's correct. You have to consume the entity before the connection
is released. See the documentation (section 1.1.5) at
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e72


On 26 September 2011 20:19, Mohit Anchlia <mo...@gmail.com> wrote:
> On Mon, Sep 26, 2011 at 12:06 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
>> On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote:
>>> I am using 4.1.2 and trying to figure out why my threads are all
>>> waiting on this block. I have this code:
>>>
>>
>> That's because your code is leaking connections.
>
> I just added this line and it resolved the issue.                                       \
> EntityUtils.toString(entity);
>
> Wondering if it's necessary to read from the entity otherwise it holds
> on to the connection.
>
>>
>> Oleg
>>
>>> Can someone please help?
>>>
>>>       static {
>>>               cm.setMaxTotal(NO_CONN*2);
>>>               cm.setDefaultMaxPerRoute(NO_CONN);
>>>       }
>>>
>>>       private static ThreadSafeClientConnManager cm = new
>>> ThreadSafeClientConnManager();
>>>
>>>       private static HttpClient httpclient = new DefaultHttpClient(cm);
>>>
>>>
>>>                       StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);
>>>
>>>                       httpput.setEntity(stringEntity);
>>>
>>>                       HttpResponse response = httpclient.execute(httpput);
>>>
>>>
>>> "pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
>>> on condition [0x00000000446f7000]
>>>    java.lang.Thread.State: WAITING (parking)
>>>         at sun.misc.Unsafe.park(Native Method)
>>>         - parking to wait for  <0x000000061d5866f0> (a
>>> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>>>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
>>>         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
>>>         at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
>>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
>>>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
>>>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>>         at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
>>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
>>>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>         at java.lang.Thread.run(Thread.java:662)
>>>
>>>
>>> jars in my classpath:
>>>
>>>
>>> ls -ltr jars
>>> total 1572
>>> -rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
>>> -rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
>>> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
>>> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
>>> -rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
>>> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
>>> -rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
>>> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
>>> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
>>> -rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking

Posted by Mohit Anchlia <mo...@gmail.com>.
On Mon, Sep 26, 2011 at 12:06 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote:
>> I am using 4.1.2 and trying to figure out why my threads are all
>> waiting on this block. I have this code:
>>
>
> That's because your code is leaking connections.

I just added this line and it resolved the issue. 					\
EntityUtils.toString(entity);

Wondering if it's necessary to read from the entity otherwise it holds
on to the connection.

>
> Oleg
>
>> Can someone please help?
>>
>>       static {
>>               cm.setMaxTotal(NO_CONN*2);
>>               cm.setDefaultMaxPerRoute(NO_CONN);
>>       }
>>
>>       private static ThreadSafeClientConnManager cm = new
>> ThreadSafeClientConnManager();
>>
>>       private static HttpClient httpclient = new DefaultHttpClient(cm);
>>
>>
>>                       StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);
>>
>>                       httpput.setEntity(stringEntity);
>>
>>                       HttpResponse response = httpclient.execute(httpput);
>>
>>
>> "pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
>> on condition [0x00000000446f7000]
>>    java.lang.Thread.State: WAITING (parking)
>>         at sun.misc.Unsafe.park(Native Method)
>>         - parking to wait for  <0x000000061d5866f0> (a
>> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
>>         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
>>         at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
>>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
>>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
>>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>         at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
>>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
>>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>         at java.lang.Thread.run(Thread.java:662)
>>
>>
>> jars in my classpath:
>>
>>
>> ls -ltr jars
>> total 1572
>> -rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
>> -rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
>> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
>> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
>> -rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
>> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
>> -rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
>> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
>> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
>> -rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: 4.1.2 http client Thread in WAITING state on getEntryBlocking

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2011-09-26 at 09:04 -0700, Mohit Anchlia wrote:
> I am using 4.1.2 and trying to figure out why my threads are all
> waiting on this block. I have this code:
> 

That's because your code is leaking connections.

Oleg 

> Can someone please help?
> 
> 	static {
> 		cm.setMaxTotal(NO_CONN*2);
> 		cm.setDefaultMaxPerRoute(NO_CONN);
> 	}
> 
> 	private static ThreadSafeClientConnManager cm = new
> ThreadSafeClientConnManager();
> 
> 	private static HttpClient httpclient = new DefaultHttpClient(cm);
> 
> 
> 			StringEntity stringEntity = new StringEntity(data, HTTP.UTF_8);
> 
> 			httpput.setEntity(stringEntity);
> 
> 			HttpResponse response = httpclient.execute(httpput);
> 
> 
> "pool-1-thread-24" prio=10 tid=0x00002aaab4018000 nid=0x20df waiting
> on condition [0x00000000446f7000]
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x000000061d5866f0> (a
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
>         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
>         at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)
>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:403)
>         at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:300)
>         at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:224)
>         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>         at com.intuit.gluster.stress.ClientPost.doPut(ClientPost.java:135)
>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:142)
>         at com.intuit.gluster.stress.InsertHttpCommand.call(InsertHttpCommand.java:1)
>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:662)
> 
> 
> jars in my classpath:
> 
> 
> ls -ltr jars
> total 1572
> -rwx------ 1 root root  60686 Jan 21  2011 commons-logging-1.1.1.jar
> -rwx------ 1 root root  58160 Jan 21  2011 commons-codec-1.4.jar
> -rwx------ 1 root root 181200 Jul 10 12:02 httpcore-4.1.2.jar
> -rwx------ 1 root root 261809 Jul 21 11:58 commons-lang-2.4.jar
> -rwx------ 1 root root  25496 Jul 21 11:58 slf4j-api-1.6.1.jar
> -rwx------ 1 root root 481535 Jul 21 11:58 log4j-1.2.16.jar
> -rwx------ 1 root root   9753 Jul 21 11:58 slf4j-log4j12-1.6.1.jar
> -rwx------ 1 root root 105799 Jul 29 22:54 httpclient-cache-4.1.2.jar
> -rwx------ 1 root root 352254 Jul 29 22:54 httpclient-4.1.2.jar
> -rwx------ 1 root root  26890 Jul 29 22:54 httpmime-4.1.2.jar
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org