sun.misc.Signal#handle() returns the default handler when installing the first custom handler (for each signal).
On the other hand, JNR's SunMiscSignal#signal() returns the previous handler only if it is a SunMiscSignalHandler, which wraps a custom handler. When installing the first custom handler (for each signal), null is returned. The default handler is "lost".
This PR fixes that by returning an adapter for the default handler instead of null. This makes it possible to chain handlers, keeping original handler functionality.
How was this patch tested?
Added assertion in unit test.
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.159 sec - in jnr.posix.SignalTest
Also tested in a real application that installs a custom handler (logger) on top of the default functionality.
What changes were proposed in this pull request?
sun.misc.Signal#handle()
returns the default handler when installing the first custom handler (for each signal).On the other hand, JNR's
SunMiscSignal#signal()
returns the previous handler only if it is aSunMiscSignalHandler
, which wraps a custom handler. When installing the first custom handler (for each signal),null
is returned. The default handler is "lost".This PR fixes that by returning an adapter for the default handler instead of
null
. This makes it possible to chain handlers, keeping original handler functionality.How was this patch tested?
Added assertion in unit test.
Also tested in a real application that installs a custom handler (logger) on top of the default functionality.