Reader r = null; try { r = new FileReader(getProject().resolveFile(filename)); return FileUtils.readFully(r); } finally { FileUtils.close(r); }
InputStream is = null; try { is = resources[i].getInputStream(); zipFile(is, zOut, name, resources[i].getLastModified(), null, ArchiveFileSet.DEFAULT_FILE_MODE); } finally { FileUtils.close(is); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Zip.java
Method name: String getFileString(String) Method name: void addResources(ResourceCollection, Resource[], ZipOutputStream)
Number of AST nodes: 4 Number of AST nodes: 4
1
Reader r = null;
1
InputStream is = null;
2
        try {
2
                    try {
3
            r = new FileReader(getProject().resolveFile(file
3
                        is = resources[i].getInputStream();
4
name));
4
                        zipFile(is, zOut, name,
5
            return  FileUtils.readFully(r);
5
            
6
                    resources[i].getLastModified(),
7
                                null, ArchiveFileSet.DEFAULT_FILE_MODE);
6
        }
8
            
7
        finally {
9
        } finally {
8
            FileUtils.close(r);
10
                        FileUtils.close(is);
9
        }
11
                    }
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.1
Clones locationClones are in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    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.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Reader r = null;
                                      
                                                    
    21
    InputStream is = null;
    2
    try
    2
    try
    22
    try
    Differences
    Expression1Expression2Difference
    risVARIABLE_NAME_MISMATCH
    java.io.Readerjava.io.InputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.Reader of variable r does not match with type java.io.InputStream of variable is
    • Make classes java.io.Reader and java.io.InputStream extend a common superclass
    22
    try
    3
    r = new FileReader(getProject().resolveFile(filename));
                                                                                                                    
    4
    return FileUtils.readFully(r);
    4
    return FileUtils.readFully(r);
    Preondition Violations
    Unmatched statement return FileUtils.readFully(r); 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
    Unmatched return FileUtils.readFully(r);
                                                                      
                                                                              
    23
    is = resources[i].getInputStream();
                                                                                                                                                                                                  
    24
    zipFile(is, zOut, name, resources[i].getLastModified(), null, ArchiveFileSet.DEFAULT_FILE_MODE);
    Preondition Violations
    Unmatched statement zipFile(is,zOut,name,resources[i].getLastModified(),null,ArchiveFileSet.DEFAULT_FILE_MODE); 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
    24
    zipFile(is, zOut, name, resources[i].getLastModified(), null, ArchiveFileSet.DEFAULT_FILE_MODE);
    Precondition Violations (4)
    Row Violation
    1Type java.io.Reader of variable r does not match with type java.io.InputStream of variable is
    2Unmatched statement return FileUtils.readFully(r); 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
    3Unmatched return FileUtils.readFully(r);
    4Unmatched statement zipFile(is,zOut,name,resources[i].getLastModified(),null,ArchiveFileSet.DEFAULT_FILE_MODE); 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