Iterator iterator = collection.iterator(); while (iterator.hasNext()) { PreparedStatement pstmt = (PreparedStatement) iterator.next(); close(pstmt); }
if (samples != null) { Iterator iter = samples.iterator(); while (iter.hasNext()) { SampleEvent e = (SampleEvent) iter.next(); sampleOccurred(e); } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/samplers/RemoteSampleListenerImpl.java
Method name: void closeAllStatements(Collection) Method name: void processBatch(List)
Number of AST nodes: 4 Number of AST nodes: 5
1
Iterator iterator = collection
1
if (samples != null) {
2
.iterator();
2
    		Iterator iter = samples.iterator();
3
		while (iterator.hasNext()) {
3
			while (iter.hasNext()) {
4
			PreparedStatement pstmt = (PreparedStatement) iterator.next();
4
				SampleEvent e = (SampleEvent) iter.next();
5
			close(pstmt);
5
				sampleOccurred(e);
6
			}
6
		}
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 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.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Iterator iterator = collection.iterator();
    1
    Iterator iterator = collection.iterator();
    2
    Iterator iter = samples.iterator();
    Differences
    Expression1Expression2Difference
    iteratoriterVARIABLE_NAME_MISMATCH
    collectionsamplesVARIABLE_NAME_MISMATCH
    java.util.Collectionjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection of variable collection does not match with type java.util.List of variable samples
    • Make classes java.util.Collection and java.util.List extend a common superclass
    2
    Iterator iter = samples.iterator();
    2
    while (iterator.hasNext())
    2
    while (iterator.hasNext())
    3
    while (iter.hasNext())
    Differences
    Expression1Expression2Difference
    iteratoriterVARIABLE_NAME_MISMATCH
    3
    while (iter.hasNext())
    3
    PreparedStatement pstmt = (PreparedStatement)iterator.next();
    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
                                                                                                                                
                                                                                        
    4
    SampleEvent e = (SampleEvent)iter.next();
    Preondition Violations
    Unmatched statement SampleEvent e=(SampleEvent)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    SampleEvent e = (SampleEvent)iter.next();
    4
    close(pstmt);
                                    
                                              
    5
    sampleOccurred(e);
    Preondition Violations
    Unmatched statement sampleOccurred(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    sampleOccurred(e);
    Precondition Violations (4)
    Row Violation
    1Type java.util.Collection of variable collection does not match with type java.util.List of variable samples
    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 e=(SampleEvent)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement sampleOccurred(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted