23
23
import org .eclipse .jetty .io .ByteBufferPool ;
24
24
import org .eclipse .jetty .io .MappedByteBufferPool ;
25
25
import org .eclipse .jetty .util .ProcessorUtils ;
26
- import org .eclipse .jetty .util .component .ContainerLifeCycle ;
26
+ import org .eclipse .jetty .util .component .LifeCycle ;
27
27
import org .eclipse .jetty .util .thread .QueuedThreadPool ;
28
28
import org .eclipse .jetty .util .thread .ScheduledExecutorScheduler ;
29
29
import org .eclipse .jetty .util .thread .Scheduler ;
@@ -127,7 +127,6 @@ public void afterPropertiesSet() throws Exception {
127
127
if (this .executor == null ) {
128
128
QueuedThreadPool threadPool = new QueuedThreadPool ();
129
129
threadPool .setName (name );
130
- threadPool .start ();
131
130
this .executor = threadPool ;
132
131
}
133
132
if (this .byteBufferPool == null ) {
@@ -137,19 +136,32 @@ public void afterPropertiesSet() throws Exception {
137
136
: ProcessorUtils .availableProcessors () * 2 );
138
137
}
139
138
if (this .scheduler == null ) {
140
- Scheduler scheduler = new ScheduledExecutorScheduler (name + "-scheduler" , false );
141
- scheduler .start ();
142
- this .scheduler = scheduler ;
139
+ this .scheduler = new ScheduledExecutorScheduler (name + "-scheduler" , false );
143
140
}
141
+
142
+ if (this .executor instanceof LifeCycle ) {
143
+ ((LifeCycle )this .executor ).start ();
144
+ }
145
+ this .scheduler .start ();
144
146
}
145
147
146
148
@ Override
147
149
public void destroy () throws Exception {
148
- if (this .executor instanceof ContainerLifeCycle ) {
149
- ((ContainerLifeCycle )this .executor ).stop ();
150
+ try {
151
+ if (this .executor instanceof LifeCycle ) {
152
+ ((LifeCycle )this .executor ).stop ();
153
+ }
154
+ }
155
+ catch (Throwable ex ) {
156
+ // ignore
157
+ }
158
+ try {
159
+ if (this .scheduler != null ) {
160
+ this .scheduler .stop ();
161
+ }
150
162
}
151
- if ( this . scheduler != null ) {
152
- this . scheduler . stop ();
163
+ catch ( Throwable ex ) {
164
+ // ignore
153
165
}
154
166
}
155
167
0 commit comments