From 82178b8d93c2eefcb912220c6367c0ed07e689a1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 4 Feb 2010 12:30:39 +0000 Subject: [PATCH] ignore IllegalStateException when removing shutdown hook (SPR-6793) --- .../context/support/AbstractApplicationContext.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 3f374ed31d..e1a94a08f5 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -944,7 +944,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // If we registered a JVM shutdown hook, we don't need it anymore now: // We've already explicitly closed the context. if (this.shutdownHook != null) { - Runtime.getRuntime().removeShutdownHook(this.shutdownHook); + try { + Runtime.getRuntime().removeShutdownHook(this.shutdownHook); + } + catch (IllegalStateException ex) { + // ignore - VM is already shutting down + } } } }