You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Hiranya Jayathilaka <hi...@gmail.com> on 2015/09/24 23:47:07 UTC

Problem with Shutting Down NIO HttpServer

Hi Devs,

I recently migrated an application from http-core to http-core-nio. When I try to gracefully shutdown my server, I noticed that it does not terminate cleanly. It seems to hang. A thread dump taken during this state revealed that the following thread is not getting killed:

"HTTP-listener-8080-1" #11 prio=5 os_prio=31 tid=0x00007fc934887000 nid=0x6c03 waiting on condition [0x0000000120c8d000]
   java.lang.Thread.State: WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x000000076c0697e0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
	at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

A close look at the source of HttpServer revealed that the listenerExecutorService used by this class is never shut down. Incidentally, the classic blocking implementation of HttpServer does call shutdown on the listenerExecutorService, and therefore the problem only occurs in the nio version of the library.

Is this a bug, or am I missing something? I'm using http-core-nio 4.4.3.

Thanks,
Hiranya 

--
Hiranya Jayathilaka
Mayhem Lab/RACE Lab;
Dept. of Computer Science, UCSB;  http://cs.ucsb.edu
E-mail: hiranya@cs.ucsb.edu;  Mobile: +1 (805) 895-7443
Blog: http://techfeast-hiranya.blogspot.com


Re: Problem with Shutting Down NIO HttpServer

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2015-09-24 at 14:47 -0700, Hiranya Jayathilaka wrote:
> Hi Devs,
> 
> I recently migrated an application from http-core to http-core-nio. When I try to gracefully shutdown my server, I noticed that it does not terminate cleanly. It seems to hang. A thread dump taken during this state revealed that the following thread is not getting killed:
> 
> "HTTP-listener-8080-1" #11 prio=5 os_prio=31 tid=0x00007fc934887000 nid=0x6c03 waiting on condition [0x0000000120c8d000]
>    java.lang.Thread.State: WAITING (parking)
> 	at sun.misc.Unsafe.park(Native Method)
> 	- parking to wait for  <0x000000076c0697e0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
> 	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
> 	at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
> 	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at java.lang.Thread.run(Thread.java:745)
> 
> A close look at the source of HttpServer revealed that the listenerExecutorService used by this class is never shut down. Incidentally, the classic blocking implementation of HttpServer does call shutdown on the listenerExecutorService, and therefore the problem only occurs in the nio version of the library.
> 
> Is this a bug, or am I missing something? I'm using http-core-nio 4.4.3.
> 

Yes, this looks like a bug. Please raise a JIRA for this defect.

Oleg


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