if(!hasContentTypeHeader) { HTTPFileArg file = files.length > 0? files[0] : null; if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) { connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType()); } else { // TODO: is this the correct default? connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); } } // Just append all the parameter values, and use that as the post body StringBuffer postBodyBuffer = new StringBuffer();
if(!hasContentTypeHeader) { HTTPFileArg file = files.length > 0? files[0] : null; if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) { post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType()); } else { // TODO - is this the correct default? post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED); } } // Just append all the non-empty parameter values, and use that as the post body StringBuffer postBody = new StringBuffer();
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/sampler/PostWriter.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Method name: void setHeaders(URLConnection, HTTPSampler) Method name: String sendPostData(PostMethod)
Number of AST nodes: 6 Number of AST nodes: 6
1
if(!hasContentTypeHeader) {
1
if(!hasContentTypeHeader) {
2
                        HTTPFileArg file = files.length > 0? files[0] : null;
2
                        HTTPFileArg file = files.length > 0? files[0] : null;
3
                        if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) {
3
                        if(file != null && file.getMimeType() != null && file.getMimeType().length() > 0) {
4
                            connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType());
4
                            post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType());
5
                        }
5
                        }
6
                        else {
6
                        else {
7
                            // TODO: is this the correct default?
7
                        	 // TODO - is this the correct default?
8
                            connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
8
                            post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED);
9
                        }
9
                        }
10
                    }
10
                    }
11
                    
11
                    
12
                    // Just append all the parameter values, and use that as the post body
12
                    // Just append all the non-empty parameter values, and use that as the post body
13
                    StringBuffer postBodyBuffer = new StringBuffer();
13
                    StringBuffer postBody = new StringBuffer();
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.5
Clones locationClones are in different classes
Number of node comparisons14
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)10.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    58
    if (!hasContentTypeHeader)
    58
    if (!hasContentTypeHeader)
    59
    HTTPFileArg file = files.length > 0 ? files[0] : null;
    59
    HTTPFileArg file = files.length > 0 ? files[0] : null;
    60
    if (file != null && file.getMimeType() != null && file.getMimeType().length() > 0)
    60
    if (file != null && file.getMimeType() != null && file.getMimeType().length() > 0)
                                                                                                                                        
    61
    post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType());
    Preondition Violations
    Unmatched statement post.setRequestHeader(HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    61
    post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType());
    61
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType());
    61
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType());
    Preondition Violations
    Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                    
    else
            
                                                                                                                                                                      
    62
    post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED);
    62
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
    62
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
    Preondition Violations
    Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                              
    63
    StringBuffer postBodyBuffer = new StringBuffer();
    63
    StringBuffer postBodyBuffer = new StringBuffer();
    63
    StringBuffer postBody = new StringBuffer();
    Differences
    Expression1Expression2Difference
    postBodyBufferpostBodyVARIABLE_NAME_MISMATCH
    63
    StringBuffer postBody = new StringBuffer();
    Precondition Violations (3)
    Row Violation
    1Unmatched statement post.setRequestHeader(HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted