Bug 52997 - Jmeter should not exit without saving Test Plan if saving before exit fails
Summary: Jmeter should not exit without saving Test Plan if saving before exit fails
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.6
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-28 15:53 UTC by shmulikk
Modified: 2012-05-01 14:32 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shmulikk 2012-03-28 15:53:20 UTC
If you open a script, change it and then try exit JMeter, it will ask you to save the changes, which is good practice.
The problem is that when you try to save the file and you fail to do so (i.e. when you try to write over a read only file) JMeter will exit without letting you another chance to save the file.

(might be the same in a case you don't have permissions to save to file in specific folder, but haven't tried this)
Comment 1 Philippe Mouawad 2012-04-23 20:16:27 UTC
Date: Mon Apr 23 20:15:41 2012
New Revision: 1329421

URL: http://svn.apache.org/viewvc?rev=1329421&view=rev
Log:
Bug 52997 - Jmeter should not exit without saving Test Plan if saving before exit fails

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java
   jmeter/trunk/xdocs/changes.xml
Comment 2 Sebb 2012-04-24 12:23:09 UTC
Unfortunately, the fix does not work.

File#canWrite() only returns true if the file already exists *and* can be written, so the upfront check means that test plans cannot be saved to new files.

I think the best is to deal with any problems in the catch clause, rather than trying to anticipate them.

Further testing shows that the problem is caused by the call to

ActionRouter.getInstance().doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));

before the save is attempted. 
If this is moved after the SaveService.saveTree() call, the code behaves much better. Patch to be checked in shortly.
Comment 3 Sebb 2012-04-24 12:38:21 UTC
Fixed in SVN:

URL: http://svn.apache.org/viewvc?rev=1329669&view=rev
Log:
Bug 52997 - Jmeter should not exit without saving Test Plan if saving before exit fails

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java


Note: I removed the setDirty(true) method call and the clearing of the file name.
Failure to save the file should not affect the dirty status.
Clearing the filename does not really achieve anything.

Leaving the issue open for now, in case there are further problems.
Comment 4 Sebb 2012-04-25 13:28:00 UTC
URL: http://svn.apache.org/viewvc?rev=1330275&view=rev
Log:
Bug 52997 - Jmeter should not exit without saving Test Plan if saving before exit fails
Fix crash with larger trees; only update saved copy of tree if we wrote the whole tree

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java

Hopefully issue now really fixed!
Comment 5 Philippe Mouawad 2012-05-01 13:37:33 UTC
Tests are OK for me.
Closing issue as fixed.
Comment 6 shmulikk 2012-05-01 14:32:15 UTC
Works for me too with r1332261.
Comment 7 The ASF infrastructure team 2022-09-24 20:37:49 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2798