149-2-3

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);

See real code fragment |  | See real code fragment

Summary
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) | 0.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 6

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 2
   Number of unmapped statements in the first code fragment | 2
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 1.2
   Clone type | Type 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
   Expression1 | Expression2 | Difference
   --- | --- | ---
   fis | rs | VARIABLE_NAME_MISMATCH
   java.io.FileInputStream | java.sql.ResultSet | VARIABLE_TYPE_MISMATCH
   fis | rs | VARIABLE_NAME_MISMATCH
   java.io.FileInputStream | java.sql.ResultSet | VARIABLE_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
   Expression1 | Expression2 | Difference
   --- | --- | ---
   load | printResults | METHOD_INVOCATION_NAME_MISMATCH
   props.load(fis) | printResults(rs,out) | ARGUMENT_NUMBER_MISMATCH
   props |  | MISSING_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
   --- | ---
   1 | Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
   2 | Type java.io.FileInputStream of variable fis does not match with type java.sql.ResultSet of variable rs
   3 | Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
   4 | Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
   5 | Expression props.load(fis) is a void method call, and thus it cannot be parameterized
   6 | Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
   7 | Expression props.load(fis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
   8 | Expression printResults(rs,out) is a method call throwing exception(s) that should be caught by a try block that will be extracted
   9 | Expression props.load(fis) is a void method call, and thus it cannot be parameterized
   10 | Expression printResults(rs,out) is a void method call, and thus it cannot be parameterized
   11 | Unmatched statement addProperties(props); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted