@@ -67,25 +67,15 @@ private void doShutdown(GracefulShutdownCallback callback, CountDownLatch shutdo
67
67
List <Connector > connectors = getConnectors ();
68
68
connectors .forEach (this ::close );
69
69
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 );
83
74
}
84
- catch (InterruptedException ex ) {
85
- Thread .currentThread ().interrupt ();
75
+ else {
76
+ logger .info ("Graceful shutdown complete" );
77
+ callback .shutdownComplete (GracefulShutdownResult .IDLE );
86
78
}
87
- logger .info ("Graceful shutdown complete" );
88
- callback .shutdownComplete (GracefulShutdownResult .IDLE );
89
79
}
90
80
finally {
91
81
shutdownUnderway .countDown ();
@@ -105,6 +95,22 @@ private void close(Connector connector) {
105
95
connector .getProtocolHandler ().closeServerSocketGraceful ();
106
96
}
107
97
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
+
108
114
private boolean isActive (Container context ) {
109
115
try {
110
116
if (((StandardContext ) context ).getInProgressAsyncCount () > 0 ) {
0 commit comments