@@ -67,25 +67,15 @@ private void doShutdown(GracefulShutdownCallback callback, CountDownLatch shutdo
6767 List <Connector > connectors = getConnectors ();
6868 connectors .forEach (this ::close );
6969 shutdownUnderway .countDown ();
70- try {
71- for (Container host : this .tomcat .getEngine ().findChildren ()) {
72- for (Container context : host .findChildren ()) {
73- while (!this .aborted && isActive (context )) {
74- Thread .sleep (50 );
75- }
76- if (this .aborted ) {
77- logger .info ("Graceful shutdown aborted with one or more requests still active" );
78- callback .shutdownComplete (GracefulShutdownResult .REQUESTS_ACTIVE );
79- return ;
80- }
81- }
82- }
70+ awaitInactiveOrAborted ();
71+ if (this .aborted ) {
72+ logger .info ("Graceful shutdown aborted with one or more requests still active" );
73+ callback .shutdownComplete (GracefulShutdownResult .REQUESTS_ACTIVE );
8374 }
84- catch (InterruptedException ex ) {
85- Thread .currentThread ().interrupt ();
75+ else {
76+ logger .info ("Graceful shutdown complete" );
77+ callback .shutdownComplete (GracefulShutdownResult .IDLE );
8678 }
87- logger .info ("Graceful shutdown complete" );
88- callback .shutdownComplete (GracefulShutdownResult .IDLE );
8979 }
9080 finally {
9181 shutdownUnderway .countDown ();
@@ -105,6 +95,22 @@ private void close(Connector connector) {
10595 connector .getProtocolHandler ().closeServerSocketGraceful ();
10696 }
10797
98+ private void awaitInactiveOrAborted () {
99+ try {
100+ for (Container host : this .tomcat .getEngine ().findChildren ()) {
101+ for (Container context : host .findChildren ()) {
102+ while (!this .aborted && isActive (context )) {
103+ Thread .sleep (50 );
104+ }
105+ }
106+ }
107+
108+ }
109+ catch (InterruptedException ex ) {
110+ Thread .currentThread ().interrupt ();
111+ }
112+ }
113+
108114 private boolean isActive (Container context ) {
109115 try {
110116 if (((StandardContext ) context ).getInProgressAsyncCount () > 0 ) {
0 commit comments