try {
DataSources.destroy( ds );
}
catch ( SQLException sqle ) {
log.warn( "could not destroy C3P0 connection pool", sqle );
}
if ( orphan.getTransaction() != null && orphan.getTransaction().isActive() ) {
try {
orphan.getTransaction().rollback();
}
catch( Throwable t ) {
log.debug( "Unable to rollback transaction for orphaned session", t );
}
}
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/connection-c3p0/src/main/java/org/hibernate/connection/C3P0ConnectionProvider.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
|
Method name: void close()
|
|
Method name: void cleanupAnyOrphanedSession(SessionFactory)
|
Number of AST nodes: 2
|
|
Number of AST nodes: 3
|
|
1 | try {↵ | | |
|
2 | DataSources.destroy( ds );↵ | | |
|
| | | 1 | if ( orphan.getTransaction() != null && orphan.getTransaction().isActive() ) {↵
|
| | | 2 | try {↵
|
| | | 3 | orphan.getTransaction().rollback();↵
|
3 | }↵ | | 4 | }↵
|
4 | catch ( SQLException sqle ) {↵ | | 5 | catch( Throwable t ) {↵
|
5 | log.warn( "could not destroy C3P0 connection pool", sqle );↵ | | 6 | log.↵
|
| | | 7 | debug( "Unable to rollback transaction for orphaned session", t );↵
|
| | | 8 | }↵
|
6 | } | | 9 | }
|
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.2 |
Clones location | Clones are in different classes |
Number of node comparisons | 4 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
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.7 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | try | | 6 | try |
2 | | | | |
| | | 7 | orphan.getTransaction().rollback(); |
Precondition Violations (3)
Row |
Violation |
1 | Expression log.warn("could not destroy C3P0 connection pool",sqle) is a void method call, and thus it cannot be parameterized |
2 | Expression log.debug("Unable to rollback transaction for orphaned session",t) is a void method call, and thus it cannot be parameterized |
3 | Unmatched statement DataSources.destroy(ds); 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 |