2323import org .eclipse .jetty .io .ByteBufferPool ;
2424import org .eclipse .jetty .io .MappedByteBufferPool ;
2525import org .eclipse .jetty .util .ProcessorUtils ;
26- import org .eclipse .jetty .util .component .ContainerLifeCycle ;
26+ import org .eclipse .jetty .util .component .LifeCycle ;
2727import org .eclipse .jetty .util .thread .QueuedThreadPool ;
2828import org .eclipse .jetty .util .thread .ScheduledExecutorScheduler ;
2929import org .eclipse .jetty .util .thread .Scheduler ;
@@ -127,7 +127,6 @@ public void afterPropertiesSet() throws Exception {
127127 if (this .executor == null ) {
128128 QueuedThreadPool threadPool = new QueuedThreadPool ();
129129 threadPool .setName (name );
130- threadPool .start ();
131130 this .executor = threadPool ;
132131 }
133132 if (this .byteBufferPool == null ) {
@@ -137,19 +136,32 @@ public void afterPropertiesSet() throws Exception {
137136 : ProcessorUtils .availableProcessors () * 2 );
138137 }
139138 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 );
143140 }
141+
142+ if (this .executor instanceof LifeCycle ) {
143+ ((LifeCycle )this .executor ).start ();
144+ }
145+ this .scheduler .start ();
144146 }
145147
146148 @ Override
147149 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+ }
150162 }
151- if ( this . scheduler != null ) {
152- this . scheduler . stop ();
163+ catch ( Throwable ex ) {
164+ // ignore
153165 }
154166 }
155167
0 commit comments