if ( collectionLoadContexts != null ) { Iterator itr = collectionLoadContexts.values().iterator(); while ( itr.hasNext() ) { CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next(); log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext ); collectionLoadContext.cleanup(); } collectionLoadContexts.clear(); }
if ( entityLoadContexts != null ) { Iterator itr = entityLoadContexts.values().iterator(); while ( itr.hasNext() ) { EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next(); log.warn( "fail-safe cleanup (entities) : " + entityLoadContext ); entityLoadContext.cleanup(); } entityLoadContexts.clear(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java
Method name: void cleanup() Method name: void cleanup()
Number of AST nodes: 7 Number of AST nodes: 7
1
if ( collectionLoadContexts != null ) {
1
if ( entityLoadContexts != null ) {
2
			Iterator itr = collectionLoadContexts.values().iterator();
2
			Iterator itr = entityLoadContexts.values().iterator();
3
			while ( itr.hasNext() ) {
3
			while ( itr.hasNext() ) {
4
				CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next();
4
				EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next();
5
				log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext );
5
				log.warn( "fail-safe cleanup (entities) : " + entityLoadContext );
6
				collectionLoadContext.cleanup();
6
				entityLoadContext.cleanup();
7
			}
7
			}
8
			collectionLoadContexts.clear();
8
			entityLoadContexts.clear();
9
		}
9
		}
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.2
Clones locationClones are in the same method
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (collectionLoadContexts != null)
    1
    if (collectionLoadContexts != null)
    8
    if (entityLoadContexts != null)
    Differences
    Expression1Expression2Difference
    collectionLoadContextsentityLoadContextsVARIABLE_NAME_MISMATCH
    8
    if (entityLoadContexts != null)
    2
    Iterator itr = collectionLoadContexts.values().iterator();
    2
    Iterator itr = collectionLoadContexts.values().iterator();
    9
    Iterator itr = entityLoadContexts.values().iterator();
    Differences
    Expression1Expression2Difference
    collectionLoadContextsentityLoadContextsVARIABLE_NAME_MISMATCH
    9
    Iterator itr = entityLoadContexts.values().iterator();
    3
    while (itr.hasNext())
    10
    while (itr.hasNext())
    4
    CollectionLoadContext collectionLoadContext = (CollectionLoadContext)itr.next();
    4
    CollectionLoadContext collectionLoadContext = (CollectionLoadContext)itr.next();
    Preondition Violations
    Unmatched statement CollectionLoadContext collectionLoadContext=(CollectionLoadContext)itr.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                      
                                                                                                                                                
    11
    EntityLoadContext entityLoadContext = (EntityLoadContext)itr.next();
    Preondition Violations
    Unmatched statement EntityLoadContext entityLoadContext=(EntityLoadContext)itr.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    EntityLoadContext entityLoadContext = (EntityLoadContext)itr.next();
    5
    log.warn("fail-safe cleanup (collections) : " + collectionLoadContext);
    5
    log.warn("fail-safe cleanup (collections) : " + collectionLoadContext);
    12
    log.warn("fail-safe cleanup (entities) : " + entityLoadContext);
    Differences
    Expression1Expression2Difference
    "fail-safe cleanup (collections) : ""fail-safe cleanup (entities) : "LITERAL_VALUE_MISMATCH
    collectionLoadContextentityLoadContextVARIABLE_NAME_MISMATCH
    org.hibernate.engine.loading.CollectionLoadContextorg.hibernate.engine.loading.EntityLoadContextVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.engine.loading.CollectionLoadContext of variable collectionLoadContext does not match with type org.hibernate.engine.loading.EntityLoadContext of variable entityLoadContext
    • Make classes org.hibernate.engine.loading.CollectionLoadContext and org.hibernate.engine.loading.EntityLoadContext extend a common superclass
    12
    log.warn("fail-safe cleanup (entities) : " + entityLoadContext);
    6
    collectionLoadContext.cleanup();
    6
    collectionLoadContext.cleanup();
    13
    entityLoadContext.cleanup();
    Differences
    Expression1Expression2Difference
    collectionLoadContextentityLoadContextVARIABLE_NAME_MISMATCH
    org.hibernate.engine.loading.CollectionLoadContextorg.hibernate.engine.loading.EntityLoadContextVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.engine.loading.CollectionLoadContext of variable collectionLoadContext does not match with type org.hibernate.engine.loading.EntityLoadContext of variable entityLoadContext
    • Make classes org.hibernate.engine.loading.CollectionLoadContext and org.hibernate.engine.loading.EntityLoadContext extend a common superclass
    13
    entityLoadContext.cleanup();
    7
    collectionLoadContexts.clear();
    7
    collectionLoadContexts.clear();
    14
    entityLoadContexts.clear();
    Differences
    Expression1Expression2Difference
    collectionLoadContextsentityLoadContextsVARIABLE_NAME_MISMATCH
    14
    entityLoadContexts.clear();
    Precondition Violations (4)
    Row Violation
    1Unmatched statement CollectionLoadContext collectionLoadContext=(CollectionLoadContext)itr.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement EntityLoadContext entityLoadContext=(EntityLoadContext)itr.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type org.hibernate.engine.loading.CollectionLoadContext of variable collectionLoadContext does not match with type org.hibernate.engine.loading.EntityLoadContext of variable entityLoadContext
    4Type org.hibernate.engine.loading.CollectionLoadContext of variable collectionLoadContext does not match with type org.hibernate.engine.loading.EntityLoadContext of variable entityLoadContext