Context ctx = null;
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 );
}
}
}
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/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: 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 (Cache) 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 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are in different classes |
Number of node comparisons | 10 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.5 |
Clone type | Type 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); |
4 | return (Cache)ctx.lookup(jndiNamespace); | | | |
Precondition Violations (2)
Row |
Violation |
1 | 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 |
2 | 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 |