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; } writer.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/taskdefs/Concat.java
Method name: void copyEntryContents(OutputStream) Method name: void concatenate(char[], Writer, Reader)
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
            out.write(buf, 0, numRead);
6
            writer.write(buffer, 0, nRead);
7
        }
7
        }
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)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    while (true)
    8
    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
                                                                                          
                                                                                              
    9
    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
    9
    int nRead = in.read(buffer, 0, buffer.length);
    4
    if (numRead == -1)
    4
    if (numRead == -1)
    10
    if (nRead == -1)
    Differences
    Expression1Expression2Difference
    numReadnReadVARIABLE_NAME_MISMATCH
    10
    if (nRead == -1)
    5
    break;
    11
    break;
    6
    out.write(buf, 0, numRead);
    6
    out.write(buf, 0, numRead);
    12
    writer.write(buffer, 0, nRead);
    Differences
    Expression1Expression2Difference
    bufbufferVARIABLE_NAME_MISMATCH
    byte[]char[]VARIABLE_TYPE_MISMATCH
    outwriterVARIABLE_NAME_MISMATCH
    java.io.OutputStreamjava.io.WriterVARIABLE_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.Writer of variable writer
    • Make classes java.io.OutputStream and java.io.Writer extend a common superclass
    12
    writer.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.Writer of variable writer