Testing shutdown handlers in IDEA

Hi All,

I'm trying to test a shutdown handler, registered in an app with

Runtime.getRuntime().addShutdownHook(shutdownThread);

The idea is that, when the JVM starts to shut down, this thread (shutdownThread) will be started. For a command-line app, this includes the JVM shutting down in response to a CTRL-C interrupt, as well as a terminal Exception.

The question is: how do I emulate this when I am running the app within IDEA? Hitting CTRL-C has no effect. Can't find anything about this in the help files.

Any answers, anyone?
Many thanks,

Neil Pattinson.

2 comments

Yes, we made an attempt to support shutdown hooks in IDEA. But there
appeared so many problems with it, that we recently dropped this feature.
(In short to make hooks work we have the process to terminate itself and not
do it externally using Process.destroy. However this is not always
possible:(( )

"Neil Pattinson" <no_mail@jetbrains.com> wrote in message
news:18842731.1067419144771.JavaMail.javamailuser@localhost...

Hi All,

>

I'm trying to test a shutdown handler, registered in an app with

>

Runtime.getRuntime().addShutdownHook(shutdownThread);

>

The idea is that, when the JVM starts to shut down, this thread

(shutdownThread) will be started. For a command-line app, this includes the
JVM shutting down in response to a CTRL-C interrupt, as well as a terminal
Exception.
>

The question is: how do I emulate this when I am running the app within

IDEA? Hitting CTRL-C has no effect. Can't find anything about this in the
help files.
>

Any answers, anyone?
Many thanks,

>

Neil Pattinson.



0

Hi Evgueny,

That's a shame. Thanks for the quick reply, though.

Cheers,

Neil Pattinson.

Yes, we made an attempt to support shutdown hooks in
IDEA. But there
appeared so many problems with it, that we recently
dropped this feature.
(In short to make hooks work we have the process to
terminate itself and not
do it externally using Process.destroy. However this
is not always
possible:(( )

0

Please sign in to leave a comment.