while (iter.hasNext()) { Timer timer = (Timer) iter.next(); TestBeanHelper.prepare((TestElement) timer); sum += timer.delay(); }
while (iter.hasPrevious()) { PostProcessor ex = (PostProcessor) iter.previous(); TestBeanHelper.prepare((TestElement) ex); ex.process(); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/threads/JMeterThread.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/threads/JMeterThread.java
Method name: void delay(List) Method name: void runPostProcessors(List)
Number of AST nodes: 4 Number of AST nodes: 4
1
while (iter.hasNext()) {
1
while (iter.has
2
			Timer timer = (Timer) iter.next
2
Previous()) {
3
();
3
    			PostProcessor ex = (PostProcessor) iter.previous();
4
			TestBeanHelper.prepare((TestElement) timer);
4
    			TestBeanHelper.prepare((TestElement) 
5
			sum += timer.delay
5
ex);
6
();
6
    			ex.process();
7
		}
7
    		}
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.1
Clones locationClones are declared in the same class
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)343.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    while (iter.hasNext())
    3
    while (iter.hasNext())
    4
    while (iter.hasPrevious())
    Differences
    Expression1Expression2Difference
    hasNexthasPreviousMETHOD_INVOCATION_NAME_MISMATCH
    java.util.Iteratorjava.util.ListIteratorSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression iter.hasNext() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression iter.hasPrevious() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression iter cannot be unified with expression iter , because common superclass java.util.Iterator does not declare member(s) public abstract boolean hasPrevious()
    4
    while (iter.hasPrevious())
    4
    Timer timer = (Timer)iter.next();
    4
    Timer timer = (Timer)iter.next();
    Preondition Violations
    Unmatched statement Timer timer=(Timer)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
                                                                                                          
    5
    PostProcessor ex = (PostProcessor)iter.previous();
    Preondition Violations
    Unmatched statement PostProcessor ex=(PostProcessor)iter.previous(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    PostProcessor ex = (PostProcessor)iter.previous();
    5
    TestBeanHelper.prepare((TestElement)timer);
    5
    TestBeanHelper.prepare((TestElement)timer);
    6
    TestBeanHelper.prepare((TestElement)ex);
    Differences
    Expression1Expression2Difference
    timerexVARIABLE_NAME_MISMATCH
    org.apache.jmeter.timers.Timerorg.apache.jmeter.processor.PostProcessorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.jmeter.timers.Timer of variable timer does not match with type org.apache.jmeter.processor.PostProcessor of variable ex
    • Make classes org.apache.jmeter.timers.Timer and org.apache.jmeter.processor.PostProcessor extend a common superclass
    6
    TestBeanHelper.prepare((TestElement)ex);
    6
    sum += timer.delay();
    6
    sum += timer.delay();
    Preondition Violations
    Unmatched statement sum+=timer.delay(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                
                                    
    7
    ex.process();
    Preondition Violations
    Unmatched statement ex.process(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ex.process(); 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
    7
    ex.process();
    Precondition Violations (9)
    Row Violation
    1Expression iter.hasNext() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression iter.hasPrevious() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression iter cannot be unified with expression iter , because common superclass java.util.Iterator does not declare member(s) public abstract boolean hasPrevious()
    4Unmatched statement Timer timer=(Timer)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement PostProcessor ex=(PostProcessor)iter.previous(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Type org.apache.jmeter.timers.Timer of variable timer does not match with type org.apache.jmeter.processor.PostProcessor of variable ex
    7Unmatched statement sum+=timer.delay(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement ex.process(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement ex.process(); 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