if ( log.isWarnEnabled() ) { if ( log.isDebugEnabled() && warning != null ) { message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG; log.debug( message, warning ); } while (warning != null) { StringBuffer buf = new StringBuffer(30) .append( "SQL Warning: ") .append( warning.getErrorCode() ) .append( ", SQLState: ") .append( warning.getSQLState() ); log.warn( buf.toString() ); log.warn( warning.getMessage() ); warning = warning.getNextWarning(); } }
if ( log.isErrorEnabled() ) { if ( log.isDebugEnabled() ) { message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG; log.debug( message, ex ); } while (ex != null) { StringBuffer buf = new StringBuffer(30) .append( "SQL Error: " ) .append( ex.getErrorCode() ) .append( ", SQLState: " ) .append( ex.getSQLState() ); log.warn( buf.toString() ); log.error( ex.getMessage() ); ex = ex.getNextException(); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/JDBCExceptionReporter.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/JDBCExceptionReporter.java
Method name: void logWarnings(SQLWarning, String) Method name: void logExceptions(SQLException, String)
Number of AST nodes: 9 Number of AST nodes: 9
1
if ( log.isWarnEnabled() ) {
1
if ( log.isErrorEnabled() ) {
2
			if ( log.isDebugEnabled() && warning != null ) {
2
			if ( log.isDebugEnabled() ) {
3
				message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
3
				message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
4
				log.debug( message, warning );
4
				log.debug( message, ex );
5
			}
5
			}
6
			while (warning != null) {
6
			while (ex != null) {
7
				StringBuffer buf = new StringBuffer(30)
7
				StringBuffer buf = new StringBuffer(30)
8
				        .append( "SQL Warning: ")
8
						.append( "SQL Error: " )
9
						.append( warning.getErrorCode() )
9
				        .append( ex.getErrorCode() )
10
						.append( ", SQLState: ")
10
				        .append( ", SQLState: " )
11
						.append( warning.getSQLState() );
11
				        .append( ex.getSQLState() );
12
				log.warn( buf.toString() );
12
				log.warn( buf.toString() );
13
				log.warn( warning.getMessage() );
13
				log.error( ex.getMessage() );
14
				warning = warning.getNextWarning();
14
				ex = ex.getNextException();
15
			}
15
			}
16
		}
16
		}
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 declared in the same class
Number of node comparisons30
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)8.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (log.isWarnEnabled())
    1
    if (log.isWarnEnabled())
    1
    if (log.isErrorEnabled())
    Differences
    Expression1Expression2Difference
    isWarnEnabledisErrorEnabledMETHOD_INVOCATION_NAME_MISMATCH
    1
    if (log.isErrorEnabled())
                                                          
    2
    if (log.isDebugEnabled())
    Preondition Violations
    Unmatched statement if(log.isDebugEnabled()) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    if (log.isDebugEnabled())
                                                                                                                                                                
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
                                                      
    4
    log.debug(message, ex);
    Preondition Violations
    Unmatched statement log.debug(message,ex); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    log.debug(message, ex);
    2
    if (log.isDebugEnabled() && warning != null)
    2
    if (log.isDebugEnabled() && warning != null)
    Preondition Violations
    Unmatched statement if(log.isDebugEnabled() && warning != null) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
                                                                                                                                                            
    4
    log.debug(message, warning);
    4
    log.debug(message, warning);
    Preondition Violations
    Unmatched statement log.debug(message,warning); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                
    5
    while (warning != null)
    5
    while (warning != null)
    5
    while (ex != null)
    Differences
    Expression1Expression2Difference
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    5
    while (ex != null)
    6
    StringBuffer buf = new StringBuffer(30).append("SQL Warning: ").append(warning.getErrorCode()).append(", SQLState: ").append(warning.getSQLState());
    6
    StringBuffer buf = new StringBuffer(30).append("SQL Warning: ").append(warning.getErrorCode()).append(", SQLState: ").append(warning.getSQLState());
    6
    StringBuffer buf = new StringBuffer(30).append("SQL Error: ").append(ex.getErrorCode()).append(", SQLState: ").append(ex.getSQLState());
    Differences
    Expression1Expression2Difference
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    "SQL Warning: ""SQL Error: "LITERAL_VALUE_MISMATCH
    6
    StringBuffer buf = new StringBuffer(30).append("SQL Error: ").append(ex.getErrorCode()).append(", SQLState: ").append(ex.getSQLState());
    7
    log.warn(buf.toString());
    7
    log.warn(buf.toString());
    8
    log.warn(warning.getMessage());
    8
    log.warn(warning.getMessage());
    8
    log.error(ex.getMessage());
    Differences
    Expression1Expression2Difference
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    warnerrorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression log.warn(warning.getMessage()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression log.error(ex.getMessage()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression log.warn(warning.getMessage()) is a void method call, and thus it cannot be parameterized
    Expression log.error(ex.getMessage()) is a void method call, and thus it cannot be parameterized
    8
    log.error(ex.getMessage());
    9
    warning = warning.getNextWarning();
    9
    warning = warning.getNextWarning();
    9
    ex = ex.getNextException();
    Differences
    Expression1Expression2Difference
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    getNextWarninggetNextExceptionMETHOD_INVOCATION_NAME_MISMATCH
    warningexVARIABLE_NAME_MISMATCH
    java.sql.SQLWarningjava.sql.SQLExceptionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression warning cannot be unified with expression ex , because common superclass java.sql.SQLException does not declare member(s) public java.sql.SQLWarning getNextWarning()
    Expression warning.getNextWarning() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ex.getNextException() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression warning cannot be unified with expression ex , because common superclass java.sql.SQLException does not declare member(s) public java.sql.SQLWarning getNextWarning()
    9
    ex = ex.getNextException();
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
    Differences
    Expression1Expression2Difference
    DEFAULT_WARNING_MSGDEFAULT_EXCEPTION_MSGVARIABLE_NAME_MISMATCH
    3
    message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
    Precondition Violations (12)
    Row Violation
    1Unmatched statement if(log.isDebugEnabled()) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement log.debug(message,ex); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement if(log.isDebugEnabled() && warning != null) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement log.debug(message,warning); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Expression log.warn(warning.getMessage()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression log.error(ex.getMessage()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression log.warn(warning.getMessage()) is a void method call, and thus it cannot be parameterized
    8Expression log.error(ex.getMessage()) is a void method call, and thus it cannot be parameterized
    9Expression warning cannot be unified with expression ex , because common superclass java.sql.SQLException does not declare member(s) public java.sql.SQLWarning getNextWarning()
    10Expression warning.getNextWarning() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression ex.getNextException() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression warning cannot be unified with expression ex , because common superclass java.sql.SQLException does not declare member(s) public java.sql.SQLWarning getNextWarning()