final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (bshInterpreter == null) { log.error("BeanShell not found"); return; } JMeterContext jmctx = JMeterContextService.getContext(); JMeterVariables vars = jmctx.getVariables(); Sampler sam = jmctx.getCurrentSampler(); SampleResult prev = jmctx.getPreviousResult(); try { // Add variables for access to context and variables bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$ bshInterpreter.set("vars", vars);//$NON-NLS-1$ bshInterpreter.set("sampler", sam);//$NON-NLS-1$ bshInterpreter.set("prev", prev);//$NON-NLS-1$ processFileOrScript(bshInterpreter); } catch (JMeterException e) { log.warn("Problem in BeanShell script "+e); }
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (bshInterpreter == null) { log.error("BeanShell not found"); return; } JMeterContext jmctx = JMeterContextService.getContext(); JMeterVariables vars = jmctx.getVariables(); SampleResult samp=se.getResult(); try { // Add variables for access to context and variables bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$ bshInterpreter.set("vars", vars);//$NON-NLS-1$ bshInterpreter.set("sampleEvent", se);//$NON-NLS-1$ bshInterpreter.set("sampleResult", samp);//$NON-NLS-1$ processFileOrScript(bshInterpreter); } catch (JMeterException e) { log.warn("Problem in BeanShell script "+e); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/modifiers/BeanShellPreProcessor.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/visualizers/BeanShellListener.java
Method name: void process() Method name: void sampleOccurred(SampleEvent)
Number of AST nodes: 14 Number of AST nodes: 13
1
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
1
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
2
		if (bshInterpreter == null) {
2
		if (bshInterpreter == null) {
3
        	log.error("BeanShell not found");
3
            log.error("BeanShell not found");
4
        	return;
4
            return;
5
        }
5
        }
6
        
6
        JMeterContext jmctx = JMeterContextService.getContext();
7
        JMeterContext jmctx = JMeterContextService.getContext();
7
        JMeterVariables vars = jmctx.getVariables();
8
        JMeterVariables vars = jmctx.getVariables();
8
		Sampler sam = jmctx.getCurrentSampler();
9
		SampleResult prev = jmctx.getPreviousResult();
9
        SampleResult samp=se.getResult();
10
        try {
10
        try {
11
            // Add variables for access to context and variables
11
            // Add variables for access to context and variables
12
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
12
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
13
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
13
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
14
            bshInterpreter.set("sampler", sam);//$NON-NLS-1$
14
            bshInterpreter.set("sampleEvent", se);//$NON-NLS-1$
15
            bshInterpreter.set("prev", prev);//$NON-NLS-1$
15
            bshInterpreter.set("sampleResult", samp);//$NON-NLS-1$
16
            
17
            processFileOrScript(bshInterpreter);
16
            processFileOrScript(bshInterpreter);
18
        } catch (JMeterException e) {
17
        } catch (JMeterException e) {
19
            log.warn("Problem in BeanShell script "+e);
18
            log.warn("Problem in BeanShell script "+e);
20
        }
19
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes having the same super class
Number of node comparisons84
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
    1
    final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
    2
    if (bshInterpreter == null)
    2
    if (bshInterpreter == null)
    3
    log.error("BeanShell not found");
    3
    log.error("BeanShell not found");
    4
    return;
    4
    return;
    5
    JMeterContext jmctx = JMeterContextService.getContext();
    5
    JMeterContext jmctx = JMeterContextService.getContext();
    6
    JMeterVariables vars = jmctx.getVariables();
    6
    JMeterVariables vars = jmctx.getVariables();
                                                                            
    7
    SampleResult samp = se.getResult();
    7
    Sampler sam = jmctx.getCurrentSampler();
                                                                                      
    8
    SampleResult prev = jmctx.getPreviousResult();
    8
    SampleResult prev = jmctx.getPreviousResult();
    Preondition Violations
    Unmatched statement SampleResult prev=jmctx.getPreviousResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                  
    9
    try
    8
    try
    10
    bshInterpreter.set("ctx", jmctx);
    9
    bshInterpreter.set("ctx", jmctx);
    11
    bshInterpreter.set("vars", vars);
    10
    bshInterpreter.set("vars", vars);
                                                                                      
    11
    bshInterpreter.set("sampleEvent", se);
    Preondition Violations
    Unmatched statement bshInterpreter.set("sampleEvent",se); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11
    bshInterpreter.set("sampleEvent", se);
    12
    bshInterpreter.set("sampler", sam);
    12
    bshInterpreter.set("sampler", sam);
    Preondition Violations
    Unmatched statement bshInterpreter.set("sampler",sam); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                
    13
    bshInterpreter.set("prev", prev);
    13
    bshInterpreter.set("prev", prev);
    12
    bshInterpreter.set("sampleResult", samp);
    Differences
    Expression1Expression2Difference
    "prev""sampleResult"LITERAL_VALUE_MISMATCH
    prevsampVARIABLE_NAME_MISMATCH
    12
    bshInterpreter.set("sampleResult", samp);
    14
    processFileOrScript(bshInterpreter);
    13
    processFileOrScript(bshInterpreter);
    Precondition Violations (4)
    Row Violation
    1Unmatched statement SampleResult prev=jmctx.getPreviousResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement bshInterpreter.set("sampleEvent",se); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3Unmatched statement bshInterpreter.set("sampler",sam); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4Clone fragment #1 returns variables jmctx, bshInterpreter , while Clone fragment #2 returns variables bshInterpreter