[spr-7231] tomcat does not shutdown correctly when using @scheduled created: 24/may/10 updated: 15/jan/19 resolved: 25/may/10 status: cl

[SPR-7231] Tomcat does not shutdown correctly when using @Scheduled
Created: 24/May/10 Updated: 15/Jan/19 Resolved: 25/May/10
Status:
Closed
Project:
Spring Framework
Component/s:
Core
Affects Version/s:
3.0.2
Fix Version/s:
3.0.3
Type:
Bug
Priority:
Major
Reporter:
Jens Göring
Assignee:
Juergen Hoeller
Resolution:
Complete
Votes:
0
Labels:
None
Remaining Estimate:
Not Specified
Time Spent:
Not Specified
Original Estimate:
Not Specified
Attachments:
Text File stacktrace.txt Zip Archive test.zip
Issue Links:
Related
is related to
SPR-6901
Tomcat does not shutdown correctly wh...
Closed
Days since last comment:
2 years, 37 weeks, 4 days ago
Last commented by a User:
true
Last updater:
Spring Issues
Description
When using @Scheduled, Tomcat will freeze on shutdown when using
Linux. The problem seems to be that ConcurrentTaskScheduler creates an
ScheduledExecutorService that uses non-daemon threads which prevent
Tomcat to shutdown. This bug is similar to SPR-6901, but not the same,
because I already have the fixed version and the code from the fix is
never executed in my application.
I guess the difference is that I use @Scheduled. I attached an code
example which is pretty much the same as in
http://blog.springsource.com/2010/01/05/task-scheduling-simplifications-in-spring-3-0/
When this application is deployed to Tomcat, and Tomcat is than
stopped, Tomcat freezes. I attached a stacktrace where the non-daemon
timer thread can be identified.
A solution might be to add this to ScheduledTaskRegistrar.destroy():
if (this.taskScheduler instanceof DisposableBean) { ((DisposableBean)this.taskScheduler).destroy(); }
(which is similar to the fix of SPR-6901)
And make ConcurrentTaskScheduler implement DisposableBean:
public void destroy() throws Exception { this.scheduledExecutor.shutdown(); }
These changes fix the problem for me.
Please let me know if you see another workaround but to not using
@Scheduled or patching Spring.

Jens Göring
Comments
Comment by Juergen Hoeller [ 25/May/10 ]
Good catch! I've revised ScheduledTaskRegistrar to call shutdownNow()
on any default executor that it happens to use. Since
ConcurrentTaskScheduler is supposed to be simple adapter for an
existing Executor with an external lifecycle, we're not calling
shutdownNow() there but rather in ScheduledTaskRegistrar itself -
specifically for a default executor.
This will be available in tonight's 3.0.3 snapshot. As a workaround
for the time being, specifying an externally configured scheduler bean
should avoid this problem: The lifecycle is then up to that external
bean in any case.
Juergen
Comment by Jens Göring [ 25/May/10 ]
Thanks for the quick reaction and workaround suggestion!

Jens Göring
Comment by Jens Göring [ 22/Jun/10 ]
I can confirm that 3.0.3 solves my original problem, thx for the fix!

Jens Göring
Comment by Spring Issues [ 14/Jan/19 ]
The Spring Framework has migrated to GitHub Issues. This issue
corresponds to spring-projects/spring-framework#11890.
Generated at Fri Oct 01 21:49:36 UTC 2021 using Jira
8.5.11#805011-sha1:102a195bf8687d9dd541cc7f5503132d0561ea57.

  • EQUIPO ELECTRICO DE POTENCIA Y DISTRIBUCIÓN CLAVE MCIEA
  • TRAINER GUIDE MODULE 13 CUSTOMER SERVICE PURPOSE TO PROVIDE
  • SLOGAN INSIEME PARTITE SIAM INSIEME TORNEREMO NON UNA DI
  • NR SPRAWY PG22021 GILWA MAŁA DNIA 05072021 R STRONA
  • EGÉSZSÉGÜGYI ALKALMASSÁGI KÉRDŐÍV JOGOSÍTVÁNYHOZ NÉV………………………………………………………………………………………… SZÜLETÉSI NÉV………………………………………………………………�
  • AP BIOLOGY CELLS FLASHCARD REVIEW GLYCOGEN GLYCOGEN IS A
  • GOLDEN RULES OF SIMULATION 1 VEGAS MENTALITY AT ALL
  • STATUS DEFINITION FA FIRST APPEARANCE FP FOR PLEA SD
  • HRVATSKO PLANINARSKO DRUŠTVO »ŽELJEZNIČAR« POZIVA VAS NA JEDNODNEVNI PLANINARSKI
  • 1 IMIĘ I NAZWISKO OSOBY SKŁADAJĄCEJ ZAMÓWIENIE 2 NAZWA
  • DIVIDEND PAYABLE BY FONDUL PROPRIETATEA SA – SUMMARY OF
  • MEMO TO GREEN TOWNSHIP PLANNING BOARD FROM DESIREE L
  • SECTION 10 PAY ISSUES 10 PAY ISSUES THIS
  • PLAN PARCIAL SECTOR US150201 CONDADO DE ALHAMA II (TM
  • ALLEGATO 4 WESTERN SAHARA UN ENVOY OPENS THREEDAY
  • III OBJETIVOS ESPECÍFICOS PRACTICAR Y APLICAR LAS ESTRATEGIAS
  • HSI HISTORICAL SCENE INVESTIGATION WHEN ELVIS MET NIXON DOCUMENT
  • MEMBER ACHIEVEMENT PLAN — 8 GOLD PIN APPLICATION FORM
  • MEZUNİYET SINAVI DİLEKÇESİ TC FIRAT ÜNİVERSİTESİ SİVİL HAVACILIK YÜKSEKOKULU
  • 31 DR JULIETTE PATTINSON UNIVERSITY OF STRATHCLYDE “PASSING UNNOTICED
  • ENTPEPARLAMENTO EUROPEOENTPE 2004 2009 DOCUMENTO DE SESIÓN DATE{25092006}2592006DATE NODOCSEB6‑05152006NODOCSE
  • MANIFIESTO POBREZA CERO LA POBREZA ES CADA VEZ MÁS
  • TALKING POINTS FOR EXTERNAL STAKEHOLDERS HOW WILL TRANSFORMATION AFFECT
  • RECURSOS AMBIENTALES EN INTERNET PORTALES DE MEDIO AMBIENTE Y
  • R E GU L A M I N PRZYZNAWANIA
  • …………………………………………ANADOLU LİSESİ …… … 2013 DERSİ FIZIK
  • ALVIN CURLING PUBLIC SCHOOL 50 UPPER ROUGE TRAIL PRINCIPAL
  • KULTŪROS PAVELDO CENTRAS VALSTYBĖS BIUDŽETINĖ KULTŪROS ĮSTAIGA AŠMENOS G
  • RUBRIKFÖRSLAG FÅR MAN PLÅGA GUDS DJUR? PUBLICERAT I GOTLANDS
  • ANNEXURE 7 – A 27 SECTION 7 STEEL