Context ctx = null; 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 ); } } }
Context ctx = null; 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/JndiMultiplexingCacheInstanceManager.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java
Method name: CacheManager locateCacheFactory(String, Properties) Method name: Object locateCache(String, Properties)
Number of AST nodes: 4 Number of AST nodes: 4
1
Context ctx = null;
1
Context ctx = null;
2
        try {
3
            
2
		try {
4
ctx = new InitialContext( jndiProperties );
3
			ctx = new InitialContext( jndiProperties );
5
            return (CacheManager) ctx.lookup( jndiNamespace );
4
			return ctx.lookup( jndiNamespace );
6
        }
7
        
5
		}
8
catch (NamingException ne) {
6
		catch (NamingException ne) {
9
            String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
7
			String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
10
            log.info( msg, ne );
8
			log.info( msg, ne );
11
            throw new CacheException( msg );
9
			throw new CacheException( msg );
12
        }
13
        finally {
14
            if ( ctx != null ) {
15
                try {
16
                    ctx.close();
17
                }
18
                
10
		}
11
		finally {
12
			if ( ctx != null ) {
13
				try {
14
					ctx.close();
15
				}
19
catch( NamingException ne ) {
16
				catch( NamingException ne ) {
20
                    log.info( "Unable to release initial context", ne );
17
					log.info( "Unable to release initial context", ne );
21
                }
22
            }
23
        
18
				}
19
			}
24
}
20
		}
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 comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Context ctx = null;
    1
    Context ctx = null;
    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 throws exception(s) that should be caught by a try block that will be extracted
    4
    return 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 throws exception(s) that should be caught by a try block that will be extracted
                                                                                                        
    Precondition Violations (2)
    Row Violation
    1Unmatched 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
    2Unmatched 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