150-2-3

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); }
in = source.getInputStream(); out = dest.getOutputStream(); byte[] buffer = new byte[FileUtils.BUF_SIZE]; int count = 0; do { out.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/Tar.java |  | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/ResourceUtils.java
Method name: `void tarResource(Resource, TarOutputStream, String, TarFileSet)` |  | Method name: `void copyResource(Resource, Resource, FilterSetCollection, Vector, boolean, boolean, String, String, Project)`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    if (!r.isDirectory()) {↵

1

    in = source.getInputStream();↵

2

                    in = r.getInputStream();↵

2

                    out = dest.getOutputStream();↵

3

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

3

                    byte[] buffer = new byte[FileUtils.BUF_SIZE];↵

4

                    int count = 0;↵

4

                    int count = 0;↵

5

                    do {↵

5

                    do {↵

6

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

6

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

7

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

7

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

8

                    } 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.1
Clones location | Clones are in different classes
Number of node comparisons | 22

1. {Refactorable}

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

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

   63

       in = r.getInputStream();

   63 | in = r.getInputStream();
   70 | in = source.getInputStream();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r | source | VARIABLE_NAME_MISMATCH

   70

       in = source.getInputStream();

   64

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

   64 | byte[] buffer = new byte[8 * 1024];
   72 | byte[] buffer = new byte[FileUtils.BUF_SIZE];

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   8 * 1024 | FileUtils.BUF_SIZE | TYPE_COMPATIBLE_REPLACEMENT

   72

       byte[] buffer = new byte[FileUtils.BUF_SIZE];

   65

       int count = 0;

   73

       int count = 0;

   68

       do while(count != -1)

   76

       do while(count != -1)

   66

       tOut.write(buffer, 0, count);

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

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

   74

       out.write(buffer, 0, count);

   67

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

   75

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

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