try
{
_transIsolation = Integer.valueOf(conn.getTransactionIsolation());
}
catch (SQLException ex)
{
String msg =
"Error saving transaction isolation.\n" +
"This might happen when reconnecting a Session to restore a broken connection.\n" +
"The new connection will use the default transaction isolation.";
s_log.error(msg, ex);
if (msgHandler == null)
{
throw ex;
}
msgHandler.showErrorMessage(msg);
}
try
{
// In case the connection won't be able to tell its Auto Commit state,
// this is the best default we have.
_autoCommit = sessionProperties.getAutoCommit();
_autoCommit = conn.getAutoCommit();
}
catch (SQLException ex)
{
String msg =
"Error saving autocommit state.\n" +
"This might happen when reconnecting a Session to restore a broken connection.\n" +
"The new connection will use the autocommit state.";
s_log.error(msg, ex);
if (msgHandler == null)
{
throw ex;
}
msgHandler.showErrorMessage(msg);
}
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/sql/SQLConnectionState.java
|
|
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/sql/SQLConnectionState.java
|
Method name: void saveState(ISQLConnection, ISessionProperties, IMessageHandler)
|
|
Method name: void saveState(ISQLConnection, ISessionProperties, IMessageHandler)
|
Number of AST nodes: 2
|
|
Number of AST nodes: 3
|
|
1 | try↵ | | 1 | try↵
|
2 | {↵ | | 2 | {↵
|
3 | _transIsolation = Integer.valueOf(conn.getTransactionIsolation()↵ | | 3 | // In case the connection won't be able to tell its Auto Commit state,↵
|
| | | 4 | // this is the best default we have.↵
|
| | | 5 | _autoCommit = sessionProperties.getAutoCommit();↵
|
|
4 | );↵ | | 6 | _autoCommit = conn.getAutoCommit();↵
|
5 | }↵ | | 7 | }↵
|
6 | catch (SQLException ex)↵ | | 8 | catch (SQLException ex)↵
|
7 | {↵ | | 9 | {↵
|
8 | String msg =↵ | | 10 | String msg =↵
|
9 | "Error saving transaction isolation.\n" +↵ | | 11 | "Error saving autocommit state.\n" +↵
|
10 | "This might happen when reconnecting a Session to restore a broken connection.\n" +↵ | | 12 | "This might happen when reconnecting a Session to restore a broken connection.\n" +↵
|
11 | "The new connection will use the default transaction isolation.";↵ | | 13 | "The new connection will use the autocommit state.";↵
|
|
|
12 | s_log.error(msg, ex);↵ | | 14 | s_log.error(msg, ex);↵
|
13 | if (msgHandler == null)↵ | | 15 | if (msgHandler == null)↵
|
14 | {↵ | | 16 | {↵
|
15 | throw ex;↵ | | 17 | throw ex;↵
|
16 | }↵ | | 18 | }↵
|
17 | msgHandler.showErrorMessage(msg);↵ | | 19 | msgHandler.showErrorMessage(msg);↵
|
18 | } | | 20 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4 |
Clones location | Clones are in the same method |
Number of node comparisons | 6 |
-
{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 | 2 |
Time elapsed for statement mapping (ms) | 0.9 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
3 | try | | 7 | try |
4 | _transIsolation = Integer.valueOf(conn.getTransactionIsolation()); | | | |
| | | 8 | _autoCommit = sessionProperties.getAutoCommit(); |
| | | 9 | _autoCommit = conn.getAutoCommit(); |
Precondition Violations (5)
Row |
Violation |
1 | Unmatched statement _transIsolation=Integer.valueOf(conn.getTransactionIsolation()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement _transIsolation=Integer.valueOf(conn.getTransactionIsolation()); 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 | Unmatched statement _autoCommit=sessionProperties.getAutoCommit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement _autoCommit=conn.getAutoCommit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement _autoCommit=conn.getAutoCommit(); 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 |