PreCollectionRecreateEventListener[] preListeners = getSession().getListeners() .getPreCollectionRecreateEventListeners(); if (preListeners.length > 0) { PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent( getPersister(), getCollection(), ( EventSource ) getSession() ); for ( int i = 0; i < preListeners.length; i++ ) { preListeners[i].onPreRecreateCollection( preEvent ); } }
PostCollectionRecreateEventListener[] postListeners = getSession().getListeners() .getPostCollectionRecreateEventListeners(); if (postListeners.length > 0) { PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent( getPersister(), getCollection(), ( EventSource ) getSession() ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostRecreateCollection( postEvent ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java
Method name: void preRecreate() Method name: void postRecreate()
Number of AST nodes: 5 Number of AST nodes: 5
1
PreCollectionRecreateEventListener[] preListeners = getSession().getListeners()
1
PostCollectionRecreateEventListener[] postListeners = getSession().getListeners()
2
				.getPreCollectionRecreateEventListeners();
2
				.getPostCollectionRecreateEventListeners();
3
		if (preListeners.length > 0) {
3
		if (postListeners.length > 0) {
4
			PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
4
			PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
5
					getPersister(), getCollection(), ( EventSource ) getSession() );
5
					getPersister(), getCollection(), ( EventSource ) getSession() );
6
			for ( int i = 0; i < preListeners.length; i++ ) {
6
			for ( int i = 0; i < postListeners.length; i++ ) {
7
				preListeners[i].onPreRecreateCollection( preEvent );
7
				postListeners[i].onPostRecreateCollection( postEvent );
8
			}
8
			}
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.3
Clones locationClones are declared in the same class
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)19.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                                                              
    1
    PostCollectionRecreateEventListener[] postListeners = getSession().getListeners().getPostCollectionRecreateEventListeners();
    1
    PreCollectionRecreateEventListener[] preListeners = getSession().getListeners().getPreCollectionRecreateEventListeners();
                                                                                                                                                                                                                                                        
    2
    if (preListeners.length > 0)
    2
    if (preListeners.length > 0)
    2
    if (postListeners.length > 0)
    Differences
    Expression1Expression2Difference
    preListenerspostListenersVARIABLE_NAME_MISMATCH
    org.hibernate.event.PreCollectionRecreateEventListener[]org.hibernate.event.PostCollectionRecreateEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable preListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PreCollectionRecreateEventListener[] and org.hibernate.event.PostCollectionRecreateEventListener[] extend a common superclass
    2
    if (postListeners.length > 0)
    3
    PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    3
    PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    3
    PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PreCollectionRecreateEventorg.hibernate.event.PostCollectionRecreateEventSUBCLASS_TYPE_MISMATCH
    preEventpostEventVARIABLE_NAME_MISMATCH
    org.hibernate.event.PreCollectionRecreateEventorg.hibernate.event.PostCollectionRecreateEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PreCollectionRecreateEventorg.hibernate.event.PostCollectionRecreateEventSUBCLASS_TYPE_MISMATCH
    3
    PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    4
    for (int i = 0; i < preListeners.length; i++)
    4
    for (int i = 0; i < preListeners.length; i++)
    4
    for (int i = 0; i < postListeners.length; i++)
    Differences
    Expression1Expression2Difference
    preListenerspostListenersVARIABLE_NAME_MISMATCH
    org.hibernate.event.PreCollectionRecreateEventListener[]org.hibernate.event.PostCollectionRecreateEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable preListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PreCollectionRecreateEventListener[] and org.hibernate.event.PostCollectionRecreateEventListener[] extend a common superclass
    4
    for (int i = 0; i < postListeners.length; i++)
                                                                                                                    
    5
    postListeners[i].onPostRecreateCollection(postEvent);
    Preondition Violations
    Unmatched statement postListeners[i].onPostRecreateCollection(postEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    postListeners[i].onPostRecreateCollection(postEvent);
    5
    preListeners[i].onPreRecreateCollection(preEvent);
    5
    preListeners[i].onPreRecreateCollection(preEvent);
    Preondition Violations
    Unmatched statement preListeners[i].onPreRecreateCollection(preEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                              
    Precondition Violations (5)
    Row Violation
    1Type int of variable preListeners.length does not match with type int of variable postListeners.length
    2Type int of variable preListeners.length does not match with type int of variable postListeners.length
    3Unmatched statement postListeners[i].onPostRecreateCollection(postEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement preListeners[i].onPreRecreateCollection(preEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables preEvent, i , while Clone fragment #2 returns variables postEvent, i