if ( maybeProxy instanceof HibernateProxy ) { HibernateProxy proxy = (HibernateProxy) maybeProxy; LazyInitializer li = proxy.getHibernateLazyInitializer(); if ( li.isUninitialized() ) { throw new PersistentObjectException( "object was an uninitialized proxy for " + li.getEntityName() ); } return li.getImplementation(); //unwrap the object } else { return maybeProxy; }
Test t = (Test) tests.nextElement(); if (t instanceof TestCase) { String name = ((TestCase) t).getName(); if (!failureExpected.contains(name + "FailureExpected")) { result.addTest(t); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java File path: /hibernate-distribution-3.3.2.GA/project/testing/src/main/java/org/hibernate/junit/UnitTestCase.java
Method name: Object unproxy(Object) Method name: TestSuite createFailureExpectedSuite(Class)
Number of AST nodes: 7 Number of AST nodes: 5
1
if ( maybeProxy instanceof HibernateProxy ) {
2
			HibernateProxy proxy = (HibernateProxy) maybeProxy;
3
			LazyInitializer li = proxy.getHibernateLazyInitializer();
4
			if ( li.isUninitialized() ) {
5
				throw new PersistentObjectException(
6
						"object was an uninitialized proxy for " +
7
						li.getEntityName()
8
				);
9
			}
10
			return li.getImplementation(); //unwrap the object
11
		}
12
		else {
13
			return maybeProxy;
14
		
1
Test t = (Test) tests.nextElement();
2
          if (t instanceof TestCase) {
3
             String name = ((TestCase) t).getName();
4
             if (!failureExpected.contains(name + "FailureExpected")) {
5
                result.addTest(t);
6
             }
15
}
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.2
Clones locationClones are in different classes
Number of node comparisons7
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)37.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    HibernateProxy proxy = (HibernateProxy)maybeProxy;
                                                                                                          
    5
    LazyInitializer li = proxy.getHibernateLazyInitializer();
                                                                                                                        
                                                                                    
    15
    String name = ((TestCase)t).getName();
    Preondition Violations
    Unmatched statement String name=((TestCase)t).getName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    String name = ((TestCase)t).getName();
    6
    if (li.isUninitialized())
    6
    if (li.isUninitialized())
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    Differences
    Expression1Expression2Difference
    li.isUninitialized()!failureExpected.contains(name + "FailureExpected")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression li.isUninitialized() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !failureExpected.contains(name + "FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    if (!failureExpected.contains(name + "FailureExpected"))
    7
    throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName());
    7
    throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName());
    Preondition Violations
    Unmatched statement throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    Unmatched throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName());
                                                                                                                                                                                                                
                                                
    17
    result.addTest(t);
    Precondition Violations (7)
    Row Violation
    1Unmatched statement String name=((TestCase)t).getName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression li.isUninitialized() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression !failureExpected.contains(name + "FailureExpected") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Unmatched statement throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    6Unmatched throw new PersistentObjectException("object was an uninitialized proxy for " + li.getEntityName());
    7The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero