hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hiranya Jayathilaka <hiranya...@gmail.com>
Subject Problem with Shutting Down NIO HttpServer
Date Thu, 24 Sep 2015 21:47:07 GMT
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.


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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message