150-1-2

out = new FileOutputStream(dest); fis = srcResource.getInputStream(); zIn = new GZIPInputStream(fis); byte[] buffer = new byte[8 * 1024]; int count = 0; do { out.write(buffer, 0, count); count = zIn.read(buffer, 0, buffer.length); } while (count != -1);
if (!r.isDirectory()) { in = r.getInputStream(); byte[] buffer = new byte[8 * 1024]; int count = 0; do { tOut.write(buffer, 0, count); count = in.read(buffer, 0, buffer.length); } while (count != -1); }

Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/GUnzip.java |  | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Tar.java
Method name: `void extract()` |  | Method name: `void tarResource(Resource, TarOutputStream, String, TarFileSet)`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    out = new FileOutputStream(dest);↵

1

    if (!r.isDirectory()) {↵

2

                    fis = srcResource.getInputStream();↵

2

                    in = r.getInputStream();↵

3

                    zIn = new GZIPInputStream(fis);↵

4

                    byte[] buffer = new byte[8 * 1024];↵

3

                    byte[] buffer = new byte[8 * 1024];↵

5

                    int count = 0;↵

4

                    int count = 0;↵

6

                    do {↵

5

                    do {↵

7

                        out.write(buffer, 0, count);↵

6

                        tOut.write(buffer, 0, count);↵

8

                        count = zIn.read(buffer, 0, buffer.length);↵

7

                        count = in.read(buffer, 0, buffer.length);↵

9

                    } while (count != -1);

8

                    } while (count != -1);↵

9

                }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 25

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 6
   Number of unmapped statements in the first code fragment | 2
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 2.6
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   9

       zIn = new GZIPInputStream(fis);

   9 | zIn = new GZIPInputStream(fis);
   63 | in = r.getInputStream();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   zIn | in | VARIABLE_NAME_MISMATCH
   java.util.zip.GZIPInputStream | java.io.InputStream | SUBCLASS_TYPE_MISMATCH
   new GZIPInputStream(fis) | r.getInputStream() | TYPE_COMPATIBLE_REPLACEMENT

   63

       in = r.getInputStream();

   10

       byte[] buffer = new byte[8 * 1024];

   64

       byte[] buffer = new byte[8 * 1024];

   11

       int count = 0;

   65

       int count = 0;

   14

       do while(count != -1)

   68

       do while(count != -1)

   12

       out.write(buffer, 0, count);

   12 | out.write(buffer, 0, count);
   66 | tOut.write(buffer, 0, count);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   out | tOut | VARIABLE_NAME_MISMATCH
   java.io.FileOutputStream | org.apache.tools.tar.TarOutputStream | SUBCLASS_TYPE_MISMATCH

   66

       tOut.write(buffer, 0, count);

   13

       count = zIn.read(buffer, 0, buffer.length);

   13 | count = zIn.read(buffer, 0, buffer.length);
   67 | count = in.read(buffer, 0, buffer.length);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   zIn | in | VARIABLE_NAME_MISMATCH
   java.util.zip.GZIPInputStream | java.io.InputStream | SUBCLASS_TYPE_MISMATCH

   67

       count = in.read(buffer, 0, buffer.length);

   Precondition Violations (0)
   Row | Violation
   --- | ---