Session current = existingSession( factory ); if ( current == null ) { throw new HibernateException( "No session currently bound to execution context" ); } return current;
Object resolved = parse( name ); if ( resolved == null ) { throw new InvalidObjectException( "unknown result style [" + name + "]" ); } return resolved;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/context/ManagedSessionContext.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java
Method name: Session currentSession() Method name: Object readResolve()
Number of AST nodes: 4 Number of AST nodes: 4
1
Session current = existingSession( factory );
1
Object resolved = parse( name );
2
		if ( current == null ) {
2
		if ( resolved == null ) {
3
			throw new HibernateException( "No session currently bound to execution context" );
3
			throw new InvalidObjectException( "unknown result style [" + name + "]" );
4
		}
4
		}
5
		return current;
5
		return resolved;
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 comparisons8
  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)0.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                  
    1
    Object resolved = parse(name);
    1
    Session current = existingSession(factory);
                                                                                            
    2
    if (current == null)
    2
    if (current == null)
    2
    if (resolved == null)
    Differences
    Expression1Expression2Difference
    currentresolvedVARIABLE_NAME_MISMATCH
    org.hibernate.classic.Sessionjava.lang.ObjectVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.classic.Session of variable current does not match with type java.lang.Object of variable resolved
    • Make classes org.hibernate.classic.Session and java.lang.Object extend a common superclass
    2
    if (resolved == null)
    3
    throw new HibernateException("No session currently bound to execution context");
    3
    throw new HibernateException("No session currently bound to execution context");
    3
    throw new InvalidObjectException("unknown result style [" + name + "]");
    Differences
    Expression1Expression2Difference
    org.hibernate.HibernateExceptionjava.io.InvalidObjectExceptionSUBCLASS_TYPE_MISMATCH
    "No session currently bound to execution context""unknown result style [" + name + "]"TYPE_COMPATIBLE_REPLACEMENT
    3
    throw new InvalidObjectException("unknown result style [" + name + "]");
                                          
    4
    return resolved;
    Preondition Violations
    Unmatched return resolved;
    4
    return resolved;
    4
    return current;
    4
    return current;
    Preondition Violations
    Unmatched return current;
                                        
    Precondition Violations (3)
    Row Violation
    1Type org.hibernate.classic.Session of variable current does not match with type java.lang.Object of variable resolved
    2Unmatched return resolved;
    3Unmatched return current;