if (BZIP2.equals(v)) { final char[] magic = new char[] {'B', 'Z'}; for (int i = 0; i < magic.length; i++) { if (istream.read() != magic[i]) { throw new BuildException( "Invalid bz2 file." + name); } } return new CBZip2InputStream(istream); }
for (int i = 0; i < MAGIC.length; i++) { if (in.read() != MAGIC[i]) { throw new IOException("Invalid bz2 stream."); } } return new CBZip2InputStream(in);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Untar.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/BZip2Resource.java
Method name: InputStream decompress(String, InputStream) Method name: InputStream wrapStream(InputStream)
Number of AST nodes: 6 Number of AST nodes: 4
1
if (BZIP2.equals(v)) {
2
                    final char[] magic = new char[] {'B', 'Z'};
3
                    for (int i = 0; i < magic.length; i++) {
1
for (int i = 0; i < MAGIC.length; i++) {
4
                        if (istream.read() != magic[i]) {
2
            if (in.read() != MAGIC[i]) {
5
                            throw new BuildException(
3
                throw new IOException(
6
                                                     "Invalid bz2 file." + name);
7
                        }
8
                    }
9
            
4
"Invalid bz2 stream.");
5
            }
6
        }
10
        return new CBZip2InputStream(istream);
7
        return new CBZip2InputStream(i
11
                }
8
n);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.4
Clones locationClones are in different classes
Number of node comparisons7
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    5
    final char[] magic = new char[] {'B', 'Z'};
                                                                                        
    6
    for (int i = 0; i < magic.length; i++)
    6
    for (int i = 0; i < magic.length; i++)
    1
    for (int i = 0; i < MAGIC.length; i++)
    Differences
    Expression1Expression2Difference
    magicMAGICVARIABLE_NAME_MISMATCH
    1
    for (int i = 0; i < MAGIC.length; i++)
    7
    if (istream.read() != magic[i])
    7
    if (istream.read() != magic[i])
    2
    if (in.read() != MAGIC[i])
    Differences
    Expression1Expression2Difference
    istreaminVARIABLE_NAME_MISMATCH
    magicMAGICVARIABLE_NAME_MISMATCH
    2
    if (in.read() != MAGIC[i])
    8
    throw new BuildException("Invalid bz2 file." + name);
    8
    throw new BuildException("Invalid bz2 file." + name);
    3
    throw new IOException("Invalid bz2 stream.");
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.BuildExceptionjava.io.IOExceptionSUBCLASS_TYPE_MISMATCH
    "Invalid bz2 file." + name"Invalid bz2 stream."TYPE_COMPATIBLE_REPLACEMENT
    3
    throw new IOException("Invalid bz2 stream.");
    9
    return new CBZip2InputStream(istream);
    9
    return new CBZip2InputStream(istream);
    4
    return new CBZip2InputStream(in);
    Differences
    Expression1Expression2Difference
    istreaminVARIABLE_NAME_MISMATCH
    4
    return new CBZip2InputStream(in);
    Precondition Violations (0)
    Row Violation