synchronized (sampleStore) { Iterator i = sampleStore.iterator(); while (i.hasNext()) { SampleEvent se = (SampleEvent) i.next(); listener.sampleOccurred(se); } }
Iterator iterator = collection.iterator(); while (iterator.hasNext()) { PreparedStatement pstmt = (PreparedStatement) iterator.next(); close(pstmt); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/samplers/HoldSampleSender.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
Method name: void testEnded() Method name: void closeAllStatements(Collection)
Number of AST nodes: 5 Number of AST nodes: 4
1
synchronized (sampleStore) {
2
				Iterator i = sampleStore.iterator();
1
Iterator iterator = collection.iterator();
3
				while (i.hasNext()) {
2
		while (iterator.hasNext()) {
4
					SampleEvent se = (SampleEvent) i.next();
3
			PreparedStatement pstmt = (PreparedStatement) iterator.next();
5
					listener.sampleOccurred(se);
4
			
6
				}
7
	
5
close(pstmt);
8
		}
6
		}
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 in different classes
Number of node comparisons10
  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)3.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    Iterator i = sampleStore.iterator();
    4
    Iterator i = sampleStore.iterator();
    1
    Iterator iterator = collection.iterator();
    Differences
    Expression1Expression2Difference
    iiteratorVARIABLE_NAME_MISMATCH
    sampleStorecollectionVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable sampleStore does not match with type java.util.Collection of variable collection
    • Make classes java.util.List and java.util.Collection extend a common superclass
    1
    Iterator iterator = collection.iterator();
    5
    while (i.hasNext())
    5
    while (i.hasNext())
    2
    while (iterator.hasNext())
    Differences
    Expression1Expression2Difference
    iiteratorVARIABLE_NAME_MISMATCH
    2
    while (iterator.hasNext())
                                                                                                                                
    3
    PreparedStatement pstmt = (PreparedStatement)iterator.next();
    Preondition Violations
    Unmatched statement PreparedStatement pstmt=(PreparedStatement)iterator.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    PreparedStatement pstmt = (PreparedStatement)iterator.next();
                                    
    4
    close(pstmt);
    6
    SampleEvent se = (SampleEvent)i.next();
    6
    SampleEvent se = (SampleEvent)i.next();
    Preondition Violations
    Unmatched statement SampleEvent se=(SampleEvent)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    7
    listener.sampleOccurred(se);
    7
    listener.sampleOccurred(se);
    Preondition Violations
    Unmatched statement listener.sampleOccurred(se); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    Precondition Violations (4)
    Row Violation
    1Type java.util.List of variable sampleStore does not match with type java.util.Collection of variable collection
    2Unmatched statement PreparedStatement pstmt=(PreparedStatement)iterator.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement SampleEvent se=(SampleEvent)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement listener.sampleOccurred(se); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted