if (conn != null) { try { conn.close(); } catch (SQLException ex) { // i18n[ConnectToAliasCommand.error.closeconnection=Error occured closing Connection] s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"), ex); } }
if (_session != null) { try { getCommand().execute(); } catch (Exception e) { _session.showMessage(e); } }
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/mainframe/action/ConnectToAliasCommand.java File path: /sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/actions/AbstractSessionAction.java
Method name: void closeConnection(ISQLConnection) Method name: void actionPerformed(ActionEvent)
Number of AST nodes: 3 Number of AST nodes: 3
1
if (conn != null)
1
if (_session != null)
2
			{
3
				try
4
				{
5
					conn.close();
6
				}
7
				
2
 {
3
            try {
4
                getCommand().execute();
8
catch (SQLException ex)
5
            } catch (Exception e
9
				{
6
) {
10
                    // i18n[ConnectToAliasCommand.error.closeconnection=Error occured closing Connection]
7
                
11
					s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"), ex);
12
				}
13
			
8
_session.showMessage(e);
9
            }
14
}
10
        }
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)0.4
Clones locationClones are in different classes
Number of node comparisons5
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)299.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (conn != null)
    1
    if (conn != null)
    1
    if (_session != null)
    Differences
    Expression1Expression2Difference
    conn_sessionVARIABLE_NAME_MISMATCH
    net.sourceforge.squirrel_sql.fw.sql.ISQLConnectionnet.sourceforge.squirrel_sql.client.session.ISessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.fw.sql.ISQLConnection of variable conn does not match with type net.sourceforge.squirrel_sql.client.session.ISession of variable _session
    • Make classes net.sourceforge.squirrel_sql.fw.sql.ISQLConnection and net.sourceforge.squirrel_sql.client.session.ISession extend a common superclass
    1
    if (_session != null)
    2
    try
    2
    try
    2
    try
    Differences
    Expression1Expression2Difference
    java.sql.SQLExceptionjava.lang.ExceptionSUBCLASS_TYPE_MISMATCH
    exeVARIABLE_NAME_MISMATCH
    java.sql.SQLExceptionjava.lang.ExceptionSUBCLASS_TYPE_MISMATCH
    errorshowMessageMETHOD_INVOCATION_NAME_MISMATCH
    s_log_sessionVARIABLE_NAME_MISMATCH
    net.sourceforge.squirrel_sql.fw.util.log.ILoggernet.sourceforge.squirrel_sql.client.session.ISessionVARIABLE_TYPE_MISMATCH
    s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex)_session.showMessage(e)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression _session.showMessage(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) is a void method call, and thus it cannot be parameterized
    Expression _session.showMessage(e) is a void method call, and thus it cannot be parameterized
    Type net.sourceforge.squirrel_sql.fw.util.log.ILogger of variable s_log does not match with type net.sourceforge.squirrel_sql.client.session.ISession of variable _session
    • Make classes net.sourceforge.squirrel_sql.fw.util.log.ILogger and net.sourceforge.squirrel_sql.client.session.ISession extend a common superclass
    Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression _session.showMessage(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) is a void method call, and thus it cannot be parameterized
    Expression _session.showMessage(e) is a void method call, and thus it cannot be parameterized
    2
    try
                                                        
    3
    getCommand().execute();
    Preondition Violations
    Unmatched statement getCommand().execute(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement getCommand().execute(); 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
    getCommand().execute();
    3
    conn.close();
    3
    conn.close();
    Preondition Violations
    Unmatched statement conn.close(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement conn.close(); 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
                                    
    Precondition Violations (15)
    Row Violation
    1Type net.sourceforge.squirrel_sql.fw.sql.ISQLConnection of variable conn does not match with type net.sourceforge.squirrel_sql.client.session.ISession of variable _session
    2Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression _session.showMessage(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) is a void method call, and thus it cannot be parameterized
    5Expression _session.showMessage(e) is a void method call, and thus it cannot be parameterized
    6Type net.sourceforge.squirrel_sql.fw.util.log.ILogger of variable s_log does not match with type net.sourceforge.squirrel_sql.client.session.ISession of variable _session
    7Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression _session.showMessage(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression s_log.error(s_stringMgr.getString("ConnectToAliasCommand.error.closeconnection"),ex) is a void method call, and thus it cannot be parameterized
    10Expression _session.showMessage(e) is a void method call, and thus it cannot be parameterized
    11Unmatched statement getCommand().execute(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement getCommand().execute(); 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
    13Unmatched statement conn.close(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Unmatched statement conn.close(); 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
    15The refactoring of the clones is infeasible, because classes net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand.SheetHandler and net.sourceforge.squirrel_sql.plugins.postgres.actions.AbstractSessionAction do not have a common superclass