FileInputStream fis = new FileInputStream(file); try { props.load(fis); } finally { if (fis != null) { fis.close(); } } addProperties(props);
ResultSet rs = statement.getResultSet(); try { printResults(rs, out); } finally { if (rs != null) { rs.close(); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Property.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/SQLExec.java
Method name: void loadFile(File) Method name: void printResults(PrintStream)
Number of AST nodes: 4 Number of AST nodes: 3
1
FileInputStream fis = new FileInputStream(file);
2
      
1
ResultSet rs = statement.getResultSet();
3
          try {
2
        try {
4
                    props.load(fis);
3
            pr
5
        
4
intResults(rs, out);
6
        } finally {
5
        } finally {
7
                    if (fis != null) {
6
            if (rs != null) {
8
                        fis.close();
7
                rs.close();
9
            
8
            }
10
        }
9
        }
11
                }
12
                addProperties(props);
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons6
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                      
    1
    ResultSet rs = statement.getResultSet();
    5
    FileInputStream fis = new FileInputStream(file);
                                                                                                      
    6
    try
    6
    try
    2
    try
    Differences
    Expression1Expression2Difference
    fisrsVARIABLE_NAME_MISMATCH
    java.io.FileInputStreamjava.sql.ResultSetVARIABLE_TYPE_MISMATCH
    fisrsVARIABLE_NAME_MISMATCH
    java.io.FileInputStreamjava.sql.ResultSetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
    • Make classes java.io.FileInputStream and java.sql.ResultSet extend a common superclass
    Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
    • Make classes java.io.FileInputStream and java.sql.ResultSet extend a common superclass
    2
    try
    7
    props.load(fis);
    7
    props.load(fis);
    3
    printResults(rs, out);
    Differences
    Expression1Expression2Difference
    loadprintResultsMETHOD_INVOCATION_NAME_MISMATCH
    props.load(fis)printResults(rs,out)ARGUMENT_NUMBER_MISMATCH
    propsMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression props.load(fis) is a void method call, and thus it cannot be parameterized
    Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
    Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression props.load(fis) is a void method call, and thus it cannot be parameterized
    Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
    3
    printResults(rs, out);
    8
    addProperties(props);
    8
    addProperties(props);
    Preondition Violations
    Unmatched statement addProperties(props); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    Precondition Violations (11)
    Row Violation
    1Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
    2Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
    3Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    4Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    5Expression props.load(fis) is a void method call, and thus it cannot be parameterized
    6Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
    7Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    8Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    9Expression props.load(fis) is a void method call, and thus it cannot be parameterized
    10Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
    11Unmatched statement addProperties(props); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted