super.setUp(); if (getCollectionAccessStrategy() == null) { Configuration cfg = createConfiguration(); JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance(); optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC; // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null); setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); }
super.setUp(); if (getEntityAccessStrategy() == null) { Configuration cfg = createConfiguration(); JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance(); optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC; // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null); setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticTransactionalExtraAPITestCase.java File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticTransactionalExtraAPITestCase.java
Method name: void setUp() Method name: void setUp()
Number of AST nodes: 9 Number of AST nodes: 9
1
super.setUp();
1
super.setUp();
2
        
2
        
3
        if (getCollectionAccessStrategy() == null) {
3
        if (getEntityAccessStrategy() == null) {
4
            Configuration cfg = createConfiguration();
4
            Configuration cfg = createConfiguration();
5
            JBossCacheRegionFactory rf  = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
5
            JBossCacheRegionFactory rf  = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
6
            Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
6
            Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
7
            optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
7
            optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
8
            
8
            
9
            // Sleep a bit to avoid concurrent FLUSH problem
9
            // Sleep a bit to avoid concurrent FLUSH problem
10
            avoidConcurrentFlush();
10
            avoidConcurrentFlush();
11
            
11
            
12
            CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null);
12
            EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null);
13
            setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType()));
13
            setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType()));
14
        }
14
        }
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 having the same super class
Number of node comparisons65
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)71.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    super.setUp();
    1
    super.setUp();
    1
    super.setUp();
    Preondition Violations
    Super method call super.setUp(); cannot be extracted from method
    Super method call super.setUp(); cannot be extracted from method
    1
    super.setUp();
    2
    if (getCollectionAccessStrategy() == null)
    2
    if (getCollectionAccessStrategy() == null)
    2
    if (getEntityAccessStrategy() == null)
    Differences
    Expression1Expression2Difference
    getCollectionAccessStrategygetEntityAccessStrategyMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.cache.access.CollectionRegionAccessStrategyorg.hibernate.cache.access.EntityRegionAccessStrategyVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.cache.access.CollectionRegionAccessStrategy of variable getCollectionAccessStrategy() does not match with type org.hibernate.cache.access.EntityRegionAccessStrategy of variable getEntityAccessStrategy()
    • Make classes org.hibernate.cache.access.CollectionRegionAccessStrategy and org.hibernate.cache.access.EntityRegionAccessStrategy extend a common superclass
    2
    if (getEntityAccessStrategy() == null)
    3
    Configuration cfg = createConfiguration();
    3
    Configuration cfg = createConfiguration();
    4
    JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
    4
    JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
    5
    Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
    5
    Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
    6
    optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
    6
    optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
    7
    avoidConcurrentFlush();
    7
    avoidConcurrentFlush();
    8
    CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null);
    8
    CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null);
    8
    EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null);
    Differences
    Expression1Expression2Difference
    org.hibernate.cache.CollectionRegionorg.hibernate.cache.EntityRegionSUBCLASS_TYPE_MISMATCH
    localCollectionRegionlocalEntityRegionVARIABLE_NAME_MISMATCH
    org.hibernate.cache.CollectionRegionorg.hibernate.cache.EntityRegionSUBCLASS_TYPE_MISMATCH
    buildCollectionRegionbuildEntityRegionMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression rf.buildCollectionRegion(REGION_NAME,cfg.getProperties(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression rf.buildEntityRegion(REGION_NAME,cfg.getProperties(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null);
                                                                                                                                                                                      
    9
    setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType()));
    Preondition Violations
    Unmatched statement setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); 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
    9
    setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType()));
    9
    setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType()));
    9
    setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType()));
    Preondition Violations
    Unmatched statement setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); 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
                                                                                                                                                                                          
    Precondition Violations (9)
    Row Violation
    1Super method call super.setUp(); cannot be extracted from method
    2Super method call super.setUp(); cannot be extracted from method
    3Type org.hibernate.cache.access.CollectionRegionAccessStrategy of variable getCollectionAccessStrategy() does not match with type org.hibernate.cache.access.EntityRegionAccessStrategy of variable getEntityAccessStrategy()
    4Expression rf.buildCollectionRegion(REGION_NAME,cfg.getProperties(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression rf.buildEntityRegion(REGION_NAME,cfg.getProperties(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched statement setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); 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
    8Unmatched statement setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); 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