On Tue, 2010-06-01 at 22:55 +0200, Jakub wrote:
> Hey folks,
> 
> I was trying out the ThreadSafeClientConnManager example from documentation, 
> together with java executor framework and the executor.shutdown() function. 
> Is it ok to exit threads running httpClient.execute  like this ? I'm getting 
> this stack trace for each thread shutdown like this. They are usually refused 
> connections...  appreciate  any advice, Jakub
> 
> http://pastebin.com/eGjzQAy9
> http://pastebin.com/F80VRZxX
> 

Executor#shutdown() terminates worker threads by interrupting them.
While this might work, it usually can result in all sorts of funny
exceptions. Moreover, as far as I know some I/O operations cannot be
reliably unblocked by just interrupting the thread. It is recommended to
use HttpUriRequest#abort method to abort requests still being executed
and then terminate and join worker threads.

Hope this helps

Oleg

> 
> java.lang.Throwable: java.io.InterruptedIOException
>         at tools.proxies.GetThread.run(GetThread.java:88)
>         at java.lang.Thread.run(Thread.java:619)         
>         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:619)                              
>                 
> Caused by: java.io.InterruptedIOException                                     
>                 
>         at 
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:392)
>         at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
>         
>         at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:731)
>         
>         at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
>         
>         at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
>         
>         at tools.proxies.GetThread.run(GetThread.java:65)                     
>                         
>         ... 4 more                                                            
>                         
> Caused by: java.lang.InterruptedException                                     
>                         
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1899)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1934)
>                    
>         at 
> org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:158)   
>                                                       
>         at 
> org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:331)
>                                           
>         at 
> org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:228)
>                                             
>         at 
> org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:172)
>                    
>         at 
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390)
>                                          
>         ... 9 more   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to