Bug 52788 - HttpRequestHdr : Optimize code to avoid useless work
HttpRequestHdr : Optimize code to avoid useless work
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: HTTP
2.6
All All
: P2 enhancement (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-02-28 14:21 UTC by Philippe Mouawad
Modified: 2012-02-28 16:21 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2012-02-28 14:21:42 UTC
Hello,
Analyzing code I must say I don't understand what's the use of these lines in HttpRequestHdr#createSampler:

           // Damn! A whole new GUI just to instantiate a test element?
            // Isn't there a beter way?
            HttpTestSampleGui tempGui = new HttpTestSampleGui();
            sampler.setProperty(TestElement.GUI_CLASS, tempGui.getClass().getName());
            tempGui.configure(sampler);
            tempGui.modifyTestElement(sampler);


They should be in my opinion replaced by:

            sampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());


My analysis is the following:

    Configure will configure GUI from Sampler
    Then sampler is configured from GUI
    And then GUI is thrown away


Did I miss something ?

Regards
Philippe
Comment 1 Philippe Mouawad 2012-02-28 14:31:19 UTC
(In reply to comment #0)
> Hello,
> Analyzing code I must say I don't understand what's the use of these lines in
> HttpRequestHdr#createSampler:
> 
>            // Damn! A whole new GUI just to instantiate a test element?
>             // Isn't there a beter way?
>             HttpTestSampleGui tempGui = new HttpTestSampleGui();
>             sampler.setProperty(TestElement.GUI_CLASS,
> tempGui.getClass().getName());
>             tempGui.configure(sampler);
>             tempGui.modifyTestElement(sampler);
> 
> 
> They should be in my opinion replaced by:
> 
>             sampler.setProperty(TestElement.GUI_CLASS,
> HttpTestSampleGui.class.getName());
Replaced by;
            HttpTestSampleGui tempGui = new HttpTestSampleGui();
            sampler.setProperty(TestElement.GUI_CLASS,
tempGui.class.getName());
> 
> 
> My analysis is the following:
> 
>     Configure will configure GUI from Sampler
>     Then sampler is configured from GUI
>     And then GUI is thrown away
> 
> 
> Did I miss something ?
1) tempGui.configure(sampler) =>  will configure GUI from Sampler
2) tempGui.modifyTestElement(sampler);  =>  will reconfigure sampler from GUI (that has just been configured from Sampler)
3) And then tempGui is thrown away
> 
> Regards
> Philippe
Comment 2 Philippe Mouawad 2012-02-28 14:36:46 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Hello,
> > Analyzing code I must say I don't understand what's the use of these lines in
> > HttpRequestHdr#createSampler:
> > 
> >            // Damn! A whole new GUI just to instantiate a test element?
> >             // Isn't there a beter way?
> >             HttpTestSampleGui tempGui = new HttpTestSampleGui();
> >             sampler.setProperty(TestElement.GUI_CLASS,
> > tempGui.getClass().getName());
> >             tempGui.configure(sampler);
> >             tempGui.modifyTestElement(sampler);
> > 
> > 
> > They should be in my opinion replaced by:
> > 
> >             sampler.setProperty(TestElement.GUI_CLASS,
> > HttpTestSampleGui.class.getName());
> Replaced by;
>             HttpTestSampleGui tempGui = new HttpTestSampleGui();
>             sampler.setProperty(TestElement.GUI_CLASS,
> tempGui.class.getName());

Replaced by;
             sampler.setProperty(TestElement.GUI_CLASS,  HttpTestSampleGui.getClass().getName());

> > 
> > 
> > My analysis is the following:
> > 
> >     Configure will configure GUI from Sampler
> >     Then sampler is configured from GUI
> >     And then GUI is thrown away
> > 
> > 
> > Did I miss something ?
> 1) tempGui.configure(sampler) =>  will configure GUI from Sampler
> 2) tempGui.modifyTestElement(sampler);  =>  will reconfigure sampler from GUI
> (that has just been configured from Sampler)
> 3) And then tempGui is thrown away
> > 
> > Regards
> > Philippe
Comment 3 Sebb 2012-02-28 14:45:41 UTC
AFAIK, this was from before I started on JMeter.

At present, the convoluted process only results in setting the GUI_CLASS.

However, perhaps the thinking was that in future the code might change, and so it was safer to create use the normal way of creating a sampler, rather than trying to shorten the process.
Comment 4 Philippe Mouawad 2012-02-28 16:21:04 UTC
Date: Tue Feb 28 16:01:05 2012
New Revision: 1294708

URL: http://svn.apache.org/viewvc?rev=1294708&view=rev
Log:
Bug 52788 - HttpRequestHdr : Optimize code to avoid useless work

Modified:
   jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
   jmeter/trunk/xdocs/changes.xml