HTTPFileArg file = files[0]; if(!hasContentTypeHeader) { // Allow the mimetype of the file to control the content type if(file.getMimeType() != null && file.getMimeType().length() > 0) { post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType()); } else { post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED); } }
HTTPFileArg file = files[0]; if(!hasContentTypeHeader) { // Allow the mimetype of the file to control the content type if(file.getMimeType() != null && file.getMimeType().length() > 0) { connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType()); } else { connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED); } }
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/PostWriter.java
Method name: String sendPostData(PostMethod) Method name: void setHeaders(URLConnection, HTTPSampler)
Number of AST nodes: 5 Number of AST nodes: 5
1
HTTPFileArg file = files[0];
1
HTTPFileArg file = files[0];
2
                if(!hasContentTypeHeader) {
2
                if(!hasContentTypeHeader) {
3
                    // Allow the mimetype of the file to control the content type
3
                    // Allow the mimetype of the file to control the content type
4
                    if(file.getMimeType() != null && file.getMimeType().length() > 0) {
4
                    if(file.getMimeType() != null && file.getMimeType().length() > 0) {
5
                        post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType());
5
                        connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType());
6
                    }
6
                    }
7
                    else {
7
                    else {
8
                        post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED);
8
                        connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
9
                    }
9
                    }
10
                }
10
                }
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.8
Clones locationClones are in different classes
Number of node comparisons12
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)9.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    44
    HTTPFileArg file = files[0];
    45
    HTTPFileArg file = files[0];
    45
    if (!hasContentTypeHeader)
    46
    if (!hasContentTypeHeader)
    46
    if (file.getMimeType() != null && file.getMimeType().length() > 0)
    47
    if (file.getMimeType() != null && file.getMimeType().length() > 0)
    47
    post.setRequestHeader(HEADER_CONTENT_TYPE, file.getMimeType());
    47
    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
    Unmatched statement post.setRequestHeader(HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                                        
    else
            
    48
    post.setRequestHeader(HEADER_CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED);
                                                                                                                                                                      
                                                                                                                                                                                                                                              
    49
    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
    49
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
                                                                                                                                                                                    
    48
    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
    Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    48
    connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE, file.getMimeType());
    Precondition Violations (5)
    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 post.setRequestHeader(HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block 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
    4Unmatched 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
    5Unmatched statement connection.setRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE,file.getMimeType()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted