try { ctx = new InitialContext( jndiProperties ); return (CacheManager) ctx.lookup( jndiNamespace ); } catch (NamingException ne) { String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]"; log.info( msg, ne ); throw new CacheException( msg ); } finally { if ( ctx != null ) { try { ctx.close(); } catch( NamingException ne ) { log.info( "Unable to release initial context", ne ); } } }
try { ctx = new InitialContext( jndiProperties ); return (Cache) ctx.lookup( jndiNamespace ); } catch (NamingException ne) { String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]"; log.info( msg, ne ); throw new CacheException( msg ); } finally { if ( ctx != null ) { try { ctx.close(); } catch( NamingException ne ) { log.info( "Unable to release initial context", ne ); } } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/JndiMultiplexingCacheInstanceManager.java File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/JndiSharedCacheInstanceManager.java
Method name: CacheManager locateCacheFactory(String, Properties) Method name: Cache locateCache(String, Properties)
Number of AST nodes: 3 Number of AST nodes: 3
1
try {
1
try {
2
            ctx = new InitialContext( jndiProperties );
2
            ctx = new InitialContext( jndiProperties );
3
            return (CacheManager) ctx.lookup( jndiNamespace );
3
            return (Cache) ctx.lookup( jndiNamespace );
4
        }
4
        }
5
        catch (NamingException ne) {
5
        catch (NamingException ne) {
6
            String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
6
            String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
7
            log.info( msg, ne );
7
            log.info( msg, ne );
8
            throw new CacheException( msg );
8
            throw new CacheException( msg );
9
        }
9
        }
10
        finally {
10
        finally {
11
            if ( ctx != null ) {
11
            if ( ctx != null ) {
12
                try {
12
                try {
13
                    ctx.close();
13
                    ctx.close();
14
                }
14
                }
15
                catch( NamingException ne ) {
15
                catch( NamingException ne ) {
16
                    log.info( "Unable to release initial context", ne );
16
                    log.info( "Unable to release initial context", ne );
17
                }
17
                }
18
            }
18
            }
19
        }
19
        }
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.5
Clones locationClones are in different classes
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    try
    2
    try
    3
    ctx = new InitialContext(jndiProperties);
    3
    ctx = new InitialContext(jndiProperties);
                                                                                          
    4
    return (Cache)ctx.lookup(jndiNamespace);
    Preondition Violations
    Unmatched statement return (Cache)ctx.lookup(jndiNamespace); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement return (Cache)ctx.lookup(jndiNamespace); 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 return (Cache)ctx.lookup(jndiNamespace);
    4
    return (Cache)ctx.lookup(jndiNamespace);
    4
    return (CacheManager)ctx.lookup(jndiNamespace);
    4
    return (CacheManager)ctx.lookup(jndiNamespace);
    Preondition Violations
    Unmatched statement return (CacheManager)ctx.lookup(jndiNamespace); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement return (CacheManager)ctx.lookup(jndiNamespace); 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 return (CacheManager)ctx.lookup(jndiNamespace);
                                                                                                        
    Precondition Violations (6)
    Row Violation
    1Unmatched statement return (Cache)ctx.lookup(jndiNamespace); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement return (Cache)ctx.lookup(jndiNamespace); 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
    3Unmatched return (Cache)ctx.lookup(jndiNamespace);
    4Unmatched statement return (CacheManager)ctx.lookup(jndiNamespace); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement return (CacheManager)ctx.lookup(jndiNamespace); 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 return (CacheManager)ctx.lookup(jndiNamespace);