Bug 54945 - Add Shutdown Hook to enable trapping kill or CTRL+C signals
Summary: Add Shutdown Hook to enable trapping kill or CTRL+C signals
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.9
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-09 14:36 UTC by Philippe Mouawad
Modified: 2013-05-09 20:33 UTC (History)
1 user (show)



Attachments
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)
jmeter.save.saveservice.autoflush=false
Comment 1 Philippe Mouawad 2013-05-09 14:56:01 UTC
Created attachment 30267 [details]
Draft of patch

Hello,
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
Log:
Bug 54945 - Add Shutdown Hook to enable trapping kill or CTRL+C signals
Bugzilla Id: 54945

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
    jmeter/trunk/xdocs/changes.xml
Comment 5 The ASF infrastructure team 2022-09-24 20:37:53 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3120