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 ); } } }
try { ctx = new InitialContext( jndiProperties ); return 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/JndiSharedCacheInstanceManager.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java
Method name: Cache locateCache(String, Properties) Method name: Object 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 (Cache) ctx.lookup( jndiNamespace );
3
			return ctx.lookup( jndiNamespace );
4
        }
5
        
4
		}
6
catch (NamingException ne) {
5
		catch (NamingException ne) {
7
            String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
6
			String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
8
            log.info( msg, ne );
7
			log.info( msg, ne );
9
            throw new CacheException( msg );
8
			throw new CacheException( msg );
10
        }
11
        finally {
12
            if ( ctx != null ) {
13
                try {
14
                    ctx.close();
15
                }
16
                
9
		}
10
		finally {
11
			if ( ctx != null ) {
12
				try {
13
					ctx.close();
14
				}
17
catch( NamingException ne ) {
15
				catch( NamingException ne ) {
18
                    log.info( "Unable to release initial context", ne );
16
					log.info( "Unable to release initial context", ne );
19
                }
20
            }
21
        
17
				}
18
			}
22
}
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)0.9
    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 ctx.lookup(jndiNamespace);
    Preondition Violations
    Unmatched statement return 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 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 ctx.lookup(jndiNamespace);
    4
    return ctx.lookup(jndiNamespace);
    4
    return (Cache)ctx.lookup(jndiNamespace);
    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);
                                                                                          
    Precondition Violations (7)
    Row Violation
    1Unmatched statement return 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 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 ctx.lookup(jndiNamespace);
    4Unmatched 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
    5Unmatched 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
    6Unmatched return (Cache)ctx.lookup(jndiNamespace);
    7The refactoring of the clones is infeasible, because classes org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager and org.hibernate.cache.AbstractJndiBoundCacheProvider do not have a common superclass