This issue affects an unknown number of Test Elements. The Regular Expression
Extractor gui will be used as an example for this report.
The GUI panel implements the createTestElement() function by creating a new
instance of the RegexExtractor, and then passing it to the modifyTestElement()
function to initialise its parameters.
The problem with this approach is that if an existing RegexExtractor is selected
in the tree view, any newly created RegexExtractors that are created will be
pre-populated with the details of the selected RegexExtractor.
This should be changed to ensure that newly created elements are always
initialised to known default values (probably empty strings in most cases).
Existing behaviour (effectivly cloning the existing element) can be achieved via
copy/paste.

Created attachment 20119[details]
Suggested patch
The problem is caused by missing implementation of "clear" method in the GUI
classes.
This patch adds correct implementation of "clear" method for preprocessors,
postprocessors, assertions and some of the samplers.
What remains are most of the samplers, but those GUI classes are a bit complex.
It also remains to implement clear in some of the config elements.
Note that the logic controllers have been updated in patch in bug 42325.

Created attachment 20129[details]
Updated suggested patch
This updated patch also implements clear in config and samplers.
What still remains are the Java sampler and config, and the mailer and jms
samplers and configs. I have problems understanding and testing those, so I
will not fix those at the moment.

The fix seems to have caused some other problems.
For example, select a Sampler with non-default data.
Menu/Run/Clear now resets the sampler back to the default state.
The purpose of the Clear/Clear All functions is to clear the sampler data, not
the test elements.
It might be useful to implement a test element reset function, but that should
be a separate command under the Edit Menu.
The problem needs to be fixed where the new elements are created.
I'll have a further look at this.

Seems to that the clear() method() is being used for two purposes:
- clearing the GUI fields (JMeterGUIComponent interface)
- clearing data from Listeners (the Clearable interface)
One of these probably needs to be renamed.

I've done quite a bit of work to fix this (not yet committed).
After I replaced the clear() methods with clearGui() and clearData(), I then
found that there is yet another clear() method in the TestElement interface!
This is definitely not clearGui(), nor does it appear to be clearData() as it
is not used to clear runtime data.
The good news is that the Gui elements now behave better.

(In reply to comment #8)
> The refactoring was added to SVN in 544682.
>
> There are one or two Gui elements that have not yet been fixed.
I noticed when I tested today that the "Clear All" did not work for listeners,
it didn't do anything. The "clear" on just an element worked as expected.

Found the problem - the search for Clearable items looks at the userObject,
not the Gui; I had removed Clearable from ResultCollector as it did not appear
to do anything...
Fixed in r54774; Run/Clear now works again.

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.