try { if ( !connection.isClosed() ) { JDBCExceptionReporter.logAndClearWarnings( connection ); } factory.getConnectionProvider().closeConnection( connection ); connection = null; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot release connection" ); }
try { // check to see if the connection is in auto-commit // mode (no connection means aggressive connection // release outside a JTA transaction context, so MUST // be autocommit mode) boolean isAutocommit = connectionManager.isAutoCommit(); connectionManager.afterTransaction(); if ( isAutocommit ) { owner.afterTransactionCompletion(success, null); } } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( owner.getFactory().getSQLExceptionConverter(), sqle, "could not inspect JDBC autocommit mode" ); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/jdbc/ConnectionManager.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/jdbc/JDBCContext.java
Method name: void closeConnection() Method name: void afterNontransactionalQuery(boolean)
Number of AST nodes: 5 Number of AST nodes: 5
1
try {
1
try {
2
			if ( !connection.isClosed() ) {
2
			// check to see if the connection is
3
				JDBCExceptionReporter.logAndClearWarnings( connection );
4
			}
5
			factory.getConnectionProvider().closeConnection( conne
3
 in auto-commit 
4
			// mode (no connection means aggressive connection
5
			// release outside a JTA transaction context, so MUST
6
			// be autocommit mode)
7
			boolean isAutocommit = connectionManager.isAutoCommit();
6
ction );
8
			connectionManager.afterTransaction();
7
			connection = null;
9
			
10
			if ( isAutocommit ) {
11
				owner.afterTransactionCompletion(success, null);
12
			}
8
		}
13
		}
9
		catch (SQLException sqle) {
14
		catch (SQLException sqle) {
10
			throw JDBCExceptionHelper.convert( 
15
			throw JDBCExceptionHelper.convert( 
11
					factory.getSQLExceptionConverter(), 
16
					owner.getFactory().getSQLExceptionConverter(),
12
					sqle, 
17
					sqle,
13
					"Cannot release connection"
18
					"could not inspect JDBC autocommit mode"
14
				);
19
				);
15
		}
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)4.8
Clones locationClones are in different classes
Number of node comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    try
    3
    try
    2
    try
    Differences
    Expression1Expression2Difference
    factoryowner.getFactory()TYPE_COMPATIBLE_REPLACEMENT
    "Cannot release connection""could not inspect JDBC autocommit mode"LITERAL_VALUE_MISMATCH
    2
    try
                                                                                                                      
    3
    boolean isAutocommit = connectionManager.isAutoCommit();
    Preondition Violations
    Unmatched statement boolean isAutocommit=connectionManager.isAutoCommit(); 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
    3
    boolean isAutocommit = connectionManager.isAutoCommit();
                                                                                    
    4
    connectionManager.afterTransaction();
    4
    if (!connection.isClosed())
    4
    if (!connection.isClosed())
    5
    if (isAutocommit)
    Differences
    Expression1Expression2Difference
    !connection.isClosed()isAutocommitTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression !connection.isClosed() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    5
    if (isAutocommit)
    5
    JDBCExceptionReporter.logAndClearWarnings(connection);
                                                                                                                      
                                                                                                        
    6
    owner.afterTransactionCompletion(success, null);
    6
    factory.getConnectionProvider().closeConnection(connection);
                                                                                                                                  
    7
    connection = null;
                                          
    Precondition Violations (2)
    Row Violation
    1Unmatched statement boolean isAutocommit=connectionManager.isAutoCommit(); 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
    2Expression !connection.isClosed() is a method call throwing exception(s) that should be caught by a try block that will be extracted