if(post.getRequestEntity().isRepeatable()) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); post.getRequestEntity().writeRequest(bos); bos.flush(); // We get the posted bytes as UTF-8, since java is using UTF-8 postedBody.append(new String(bos.toByteArray() , "UTF-8")); // $NON-NLS-1$ bos.close(); } else { postedBody.append("<RequestEntity was not repeatable, cannot view what was sent>"); }
if(put.getRequestEntity().isRepeatable()) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); put.getRequestEntity().writeRequest(bos); bos.flush(); // We get the posted bytes as UTF-8, since java is using UTF-8 putBody.append(new String(bos.toByteArray() , "UTF-8")); // $NON-NLS-1$ bos.close(); } else { putBody.append("<RequestEntity was not repeatable, cannot view what was sent>"); }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Method name: String sendPostData(PostMethod) Method name: String sendPutData(PutMethod)
Number of AST nodes: 7 Number of AST nodes: 7
1
if(post.getRequestEntity().isRepeatable()) {
1
if(put.getRequestEntity().isRepeatable()) {
2
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
2
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
3
                    post.getRequestEntity().writeRequest(bos);
3
                put.getRequestEntity().writeRequest(bos);
4
                    bos.flush();
4
                bos.flush();
5
                    // We get the posted bytes as UTF-8, since java is using UTF-8
5
                // We get the posted bytes as UTF-8, since java is using UTF-8
6
                    postedBody.append(new String(bos.toByteArray() , "UTF-8")); // $NON-NLS-1$
6
                putBody.append(new String(bos.toByteArray() , "UTF-8")); // $NON-NLS-1$
7
                    bos.close();
7
                bos.close();
8
                }
8
            
9
   
9
}
10
             else {
10
            else {
11
                    postedBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
11
                putBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
12
                }
12
            }
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.2
Clones locationClones are declared in the same class
Number of node comparisons49
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    90
    if (post.getRequestEntity().isRepeatable())
    90
    if (post.getRequestEntity().isRepeatable())
    33
    if (put.getRequestEntity().isRepeatable())
    Differences
    Expression1Expression2Difference
    postputVARIABLE_NAME_MISMATCH
    org.apache.commons.httpclient.methods.PostMethodorg.apache.commons.httpclient.methods.PutMethodSUBCLASS_TYPE_MISMATCH
    33
    if (put.getRequestEntity().isRepeatable())
    91
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    34
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    92
    post.getRequestEntity().writeRequest(bos);
    92
    post.getRequestEntity().writeRequest(bos);
    35
    put.getRequestEntity().writeRequest(bos);
    Differences
    Expression1Expression2Difference
    postputVARIABLE_NAME_MISMATCH
    org.apache.commons.httpclient.methods.PostMethodorg.apache.commons.httpclient.methods.PutMethodSUBCLASS_TYPE_MISMATCH
    35
    put.getRequestEntity().writeRequest(bos);
    93
    bos.flush();
    36
    bos.flush();
    94
    postedBody.append(new String(bos.toByteArray(), "UTF-8"));
    94
    postedBody.append(new String(bos.toByteArray(), "UTF-8"));
    37
    putBody.append(new String(bos.toByteArray(), "UTF-8"));
    Differences
    Expression1Expression2Difference
    postedBodyputBodyVARIABLE_NAME_MISMATCH
    37
    putBody.append(new String(bos.toByteArray(), "UTF-8"));
    95
    bos.close();
    38
    bos.close();
    else
    else
    96
    postedBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
    96
    postedBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
    39
    putBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
    Differences
    Expression1Expression2Difference
    postedBodyputBodyVARIABLE_NAME_MISMATCH
    39
    putBody.append("<RequestEntity was not repeatable, cannot view what was sent>");
    Precondition Violations (0)
    Row Violation