PostCollectionRemoveEventListener[] postListeners = getSession().getListeners() .getPostCollectionRemoveEventListeners(); if (postListeners.length>0) { PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent( getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostRemoveCollection(postEvent); } }
PostInsertEventListener[] postListeners = getSession().getListeners() .getPostInsertEventListeners(); if ( postListeners.length > 0 ) { PostInsertEvent postEvent = new PostInsertEvent( getInstance(), getId(), state, getPersister(), (EventSource) getSession() ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostInsert(postEvent); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/EntityInsertAction.java
Method name: void postRemove() Method name: void postInsert()
Number of AST nodes: 5 Number of AST nodes: 5
1
PostCollectionRemoveEventListener[] postListeners = getSession().getListeners()
1
PostInsertEventListener[] postListeners = getSession().getListeners()
2
				.getPostCollectionRemoveEventListeners();
2
				.getPostInsertEventListeners();
3
		if (postListeners.length>0) {
3
		if ( postListeners.length > 0 ) {
4
			PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
4
			PostInsertEvent postEvent = new Post
5
					getPersister(), getCollection(), ( 
5
InsertEvent(
6
					getInstance(),
7
					getId(),
8
					state,
9
					getPersister(),
6
EventSource ) getSession(), affectedOwner 
10
					(EventSource) getSession()
7
);
11
			);
8
			for ( int i = 0; i < postListeners.length; i++ ) {
12
			for ( int i = 0; i < postListeners.length; i++ ) {
9
				postListeners[i].onPostRemoveCollection(postEvent);
13
				postListeners[i].onPostInsert(postEvent);
10
			}
14
			}
11
		}
15
		}
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 in different classes
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)201.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                              
    1
    PostInsertEventListener[] postListeners = getSession().getListeners().getPostInsertEventListeners();
    1
    PostCollectionRemoveEventListener[] postListeners = getSession().getListeners().getPostCollectionRemoveEventListeners();
                                                                                                                                                                                                                                                      
    2
    if (postListeners.length > 0)
    2
    if (postListeners.length > 0)
    2
    if (postListeners.length > 0)
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostInsertEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable postListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostInsertEventListener[] extend a common superclass
    2
    if (postListeners.length > 0)
    3
    PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(getPersister(), getCollection(), (EventSource)getSession(), affectedOwner);
    3
    PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(getPersister(), getCollection(), (EventSource)getSession(), affectedOwner);
    3
    PostInsertEvent postEvent = new PostInsertEvent(getInstance(), getId(), state, getPersister(), (EventSource)getSession());
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostInsertEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostInsertEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostInsertEventSUBCLASS_TYPE_MISMATCH
    new PostCollectionRemoveEvent(getPersister(),getCollection(),(EventSource)getSession(),affectedOwner)new PostInsertEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new PostInsertEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new PostInsertEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    PostInsertEvent postEvent = new PostInsertEvent(getInstance(), getId(), state, getPersister(), (EventSource)getSession());
    4
    for (int i = 0; i < postListeners.length; i++)
    4
    for (int i = 0; i < postListeners.length; i++)
    4
    for (int i = 0; i < postListeners.length; i++)
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostInsertEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable postListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostInsertEventListener[] extend a common superclass
    4
    for (int i = 0; i < postListeners.length; i++)
    5
    postListeners[i].onPostRemoveCollection(postEvent);
    5
    postListeners[i].onPostRemoveCollection(postEvent);
    5
    postListeners[i].onPostInsert(postEvent);
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostInsertEventSUBCLASS_TYPE_MISMATCH
    onPostRemoveCollectiononPostInsertMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostInsertEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression postListeners[i].onPostRemoveCollection(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression postListeners[i].onPostInsert(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression postListeners[i].onPostRemoveCollection(postEvent) is a void method call, and thus it cannot be parameterized
    Expression postListeners[i].onPostInsert(postEvent) is a void method call, and thus it cannot be parameterized
    Type org.hibernate.event.PostCollectionRemoveEventListener[] of variable postListeners does not match with type org.hibernate.event.PostInsertEventListener[] of variable postListeners
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostInsertEventListener[] extend a common superclass
    5
    postListeners[i].onPostInsert(postEvent);
    Precondition Violations (10)
    Row Violation
    1Type int of variable postListeners.length does not match with type int of variable postListeners.length
    2Expression new PostInsertEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new PostInsertEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type int of variable postListeners.length does not match with type int of variable postListeners.length
    5Expression postListeners[i].onPostRemoveCollection(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression postListeners[i].onPostInsert(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression postListeners[i].onPostRemoveCollection(postEvent) is a void method call, and thus it cannot be parameterized
    8Expression postListeners[i].onPostInsert(postEvent) is a void method call, and thus it cannot be parameterized
    9Type org.hibernate.event.PostCollectionRemoveEventListener[] of variable postListeners does not match with type org.hibernate.event.PostInsertEventListener[] of variable postListeners
    10The refactoring of the clones is infeasible, because classes org.hibernate.action.CollectionRemoveAction and org.hibernate.action.EntityInsertAction do not have a common superclass