while (true) { int numRead = this.read(buf, 0, buf.length); if (numRead == -1) { break; } out.write(buf, 0, numRead); }
while (true) { int nRead = in.read(buffer, 0, buffer.length); if (nRead == -1) { break; } out.write(buffer, 0, nRead); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/tar/TarInputStream.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/ResourceUtils.java
Method name: void copyEntryContents(OutputStream) Method name: void copyResource(Resource, Resource, FilterSetCollection, Vector, boolean, boolean, String, String, Project)
Number of AST nodes: 5 Number of AST nodes: 5
1
while (true) {
1
while (true) {
2
            int numRead = this.read(buf, 0, buf.length);
2
                    int nRead = in.read(buffer, 0, buffer.length);
3
            if (numRead == -1) {
3
                    if (nRead == -1) {
4
                break;
4
                        break;
5
            }
5
            
6
        }
6
            out.write(buf, 0, numRead);
7
                    out.write(buffer, 0, nRead);
7
        }
8
                }
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 comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    while (true)
    62
    while (true)
    3
    int numRead = this.read(buf, 0, buf.length);
    3
    int numRead = this.read(buf, 0, buf.length);
    Preondition Violations
    Unmatched statement int numRead=this.read(buf,0,buf.length); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                          
                                                                                                
    63
    int nRead = in.read(buffer, 0, buffer.length);
    Preondition Violations
    Unmatched statement int nRead=in.read(buffer,0,buffer.length); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    63
    int nRead = in.read(buffer, 0, buffer.length);
    4
    if (numRead == -1)
    4
    if (numRead == -1)
    64
    if (nRead == -1)
    Differences
    Expression1Expression2Difference
    numReadnReadVARIABLE_NAME_MISMATCH
    64
    if (nRead == -1)
    5
    break;
    65
    break;
    6
    out.write(buf, 0, numRead);
    6
    out.write(buf, 0, numRead);
    66
    out.write(buffer, 0, nRead);
    Differences
    Expression1Expression2Difference
    bufbufferVARIABLE_NAME_MISMATCH
    byte[]char[]VARIABLE_TYPE_MISMATCH
    java.io.OutputStreamjava.io.BufferedWriterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable buf does not match with type char[] of variable buffer
    • Make classes byte[] and char[] extend a common superclass
    Type java.io.OutputStream of variable out does not match with type java.io.BufferedWriter of variable out
    • Make classes java.io.OutputStream and java.io.BufferedWriter extend a common superclass
    66
    out.write(buffer, 0, nRead);
    Precondition Violations (4)
    Row Violation
    1Unmatched statement int numRead=this.read(buf,0,buf.length); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement int nRead=in.read(buffer,0,buffer.length); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type byte[] of variable buf does not match with type char[] of variable buffer
    4Type java.io.OutputStream of variable out does not match with type java.io.BufferedWriter of variable out