Bug 54945 - Add Shutdown Hook to enable trapping kill or CTRL+C signals
Add Shutdown Hook to enable trapping kill or CTRL+C signals
Product: JMeter
Classification: Unclassified
Component: Main
All All
: P2 enhancement (vote)
: ---
Assigned To: JMeter issues mailing list
Depends on:
  Show dependency tree
Reported: 2013-05-09 14:36 UTC by Philippe Mouawad
Modified: 2013-05-09 20:33 UTC (History)
1 user (show)

Draft of patch (2.20 KB, patch)
2013-05-09 14:56 UTC, Philippe Mouawad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2013-05-09 14:36:29 UTC
Necessary to avoid losing test data if kill or CTRL+C are called with the following setting (available since JMETER 2.10)
Comment 1 Philippe Mouawad 2013-05-09 14:56:01 UTC
Created attachment 30267 [details]
Draft of patch

Attached is a first proposal of Shutdown Hook implementation.
I had to add a join on StopThread otherwise it can happen exit occurs before thread is started.

Anyway there is still an issue as if shutodwn of threads takes more than jmeterengine.threadstop.wait (ThreadGroup#WAIT_TO_DIE) then it can happen that close will not be called on PrintWriter.
Comment 2 Sebb 2013-05-09 15:36:32 UTC
Note: the code in 2.9 and before used autoflush = true
Comment 3 Sebb 2013-05-09 16:13:30 UTC
Note that the shutdown hook is run even if JMeter shuts down normally.
In which case it should not call engine.stop(true).

I wonder if it would be better to implement the shutdown hook in ResultCollector instead.

That might avoid some of the problems?
Comment 4 Philippe Mouawad 2013-05-09 20:33:44 UTC
Nice idea sebb.
I commited this way.

Date: Thu May  9 20:32:55 2013
New Revision: 1480762

URL: http://svn.apache.org/r1480762
Bug 54945 - Add Shutdown Hook to enable trapping kill or CTRL+C signals
Bugzilla Id: 54945