log("Creating new property file: " + propertyfile.getAbsolutePath()); FileOutputStream out = null; try { out = new FileOutputStream(propertyfile.getAbsolutePath()); out.flush(); } finally { if (out != null) { out.close(); } }
FileWriter out = null; try { out = new FileWriter(crashFile); out.write(Constants.TERMINATED_SUCCESSFULLY + "\n"); out.flush(); } finally { if (out != null) { out.close(); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/PropertyFile.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
Method name: void readFile() Method name: void registerNonCrash()
Number of AST nodes: 5 Number of AST nodes: 5
1
log("Creating new property file: "
2
                    + propertyfile.getAbsolutePath());
3
                FileOutputStream out = null;
1
FileWriter out = null;
4
                try {
2
            try {
5
                    out = new FileOutputStream(propertyfile.getAbsolutePath());
3
                out = new File
6
    
4
Writer(crashFile);
5
                out.write(Constants.TERMINATED_SUCCESSFULLY + "\n");
7
                out.flush();
6
                out.flush();
8
                } finally {
7
            } finally {
9
                    if (out != null) {
8
                if (out != null) {
10
                        out.close();
9
                    out.close();
11
                    }
10
                
12
    
11
}
13
            }
12
            }
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
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                  
    2
    FileWriter out = null;
    10
    log("Creating new property file: " + propertyfile.getAbsolutePath());
                                                                                                                                                      
    11
    FileOutputStream out = null;
                                                                
    12
    try
    12
    try
    3
    try
    Differences
    Expression1Expression2Difference
    java.io.FileOutputStreamjava.io.FileWriterVARIABLE_TYPE_MISMATCH
    java.io.FileOutputStreamjava.io.FileWriterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out
    • Make classes java.io.FileOutputStream and java.io.FileWriter extend a common superclass
    Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out
    • Make classes java.io.FileOutputStream and java.io.FileWriter extend a common superclass
    3
    try
                                                                      
    4
    out = new FileWriter(crashFile);
                                                                                                                  
    5
    out.write(Constants.TERMINATED_SUCCESSFULLY + "\n");
    Preondition Violations
    Unmatched statement out.write(Constants.TERMINATED_SUCCESSFULLY + "\n"); 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
    5
    out.write(Constants.TERMINATED_SUCCESSFULLY + "\n");
    13
    out = new FileOutputStream(propertyfile.getAbsolutePath());
                                                                                                                              
    14
    out.flush();
    14
    out.flush();
    6
    out.flush();
    Differences
    Expression1Expression2Difference
    java.io.FileOutputStreamjava.io.FileWriterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out
    • Make classes java.io.FileOutputStream and java.io.FileWriter extend a common superclass
    6
    out.flush();
    Precondition Violations (4)
    Row Violation
    1Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out
    2Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out
    3Unmatched statement out.write(Constants.TERMINATED_SUCCESSFULLY + "\n"); 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
    4Type java.io.FileOutputStream of variable out does not match with type java.io.FileWriter of variable out