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 |
| |
See real code fragment | See real code fragment |
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) | 4.8 |
Clones location | Clones are in different classes |
Number of node comparisons | 13 |
Number of mapped statements | 2 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 1.6 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | try |
| 2 | try | |||||||||||||
|
| 3 | boolean isAutocommit = connectionManager.isAutoCommit(); | ||||||||||||||
| 4 | connectionManager.afterTransaction(); | |||||||||||||||
4 | if (!connection.isClosed()) |
| 5 | if (isAutocommit) | |||||||||||||
5 | JDBCExceptionReporter.logAndClearWarnings(connection); | | |||||||||||||||
| 6 | owner.afterTransactionCompletion(success, null); | |||||||||||||||
6 | factory.getConnectionProvider().closeConnection(connection); | | |||||||||||||||
7 | connection = null; | |
Row | Violation |
---|---|
1 | 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 |
2 | Expression !connection.isClosed() is a method call throwing exception(s) that should be caught by a try block that will be extracted |