Bug 52788

Summary: HttpRequestHdr : Optimize code to avoid useless work
Product: JMeter - Now in Github Reporter: Philippe Mouawad <p.mouawad>
Component: HTTPAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement CC: p.mouawad
Priority: P2    
Version: 2.6   
Target Milestone: ---   
Hardware: All   
OS: All   

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
Comment 5 The ASF infrastructure team 2022-09-24 20:37:49 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2757