/** * From the <code>HttpMethod</code>, store all the "set-cookie" key-pair * values in the cookieManager of the <code>UrlConfig</code>. * * @param method * <code>HttpMethod</code> which represents the request * @param u * <code>URL</code> of the URL request * @param cookieManager * the <code>CookieManager</code> containing all the cookies */ protected void saveConnectionCookies(HttpMethod method, URL u, CookieManager cookieManager) { if (cookieManager != null) { Header hdr[] = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE); for (int i = 0; i < hdr.length; i++) { cookieManager.addCookieFromHeader(hdr[i].getValue(),u); } } }
private void saveConnectionCookies(HttpResponse method, URL u, CookieManager cookieManager) { if (cookieManager != null) { Header[] hdrs = method.getHeaders(HTTPConstants.HEADER_SET_COOKIE); for (Header hdr : hdrs) { cookieManager.addCookieFromHeader(hdr.getValue(),u); } } }
Clone fragments detected by clone detection tool
File path: /apache-jmeter-2.11/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java File path: /apache-jmeter-2.11/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Method name: void saveConnectionCookies(HttpMethod, URL, CookieManager) Method name: void saveConnectionCookies(HttpResponse, URL, CookieManager)
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
private void saveConnectionCookies(HttpResponse method, URL u, CookieManager cookieManager) {
2
     * From the <code>HttpMethod</code>, store all the "set-cookie" key-pair
2
        if (cookieManager != null) {
3
     * values in the cookieManager of the <code>UrlConfig</code>.
3
            Header[] hdrs = method.getHeaders(HTTPConstants.HEADER_SET_COOKIE);
4
     *
4
            for (Header hdr : hdrs) {
5
     * @param method
5
                cookieManager.addCookieFromHeader(hdr.getValue(),u);
6
     *            <code>HttpMethod</code> which represents the request
6
            }
7
     * @param u
7
        }
8
     *            <code>URL</code> of the URL request
8
    }
9
     * @param cookieManager
10
     *            the <code>CookieManager</code> containing all the cookies
11
     */
12
    protected void saveConnectionCookies(HttpMethod method, URL u, CookieManager cookieManager) {
13
        if (cookieManager != null) {
14
            Header hdr[] = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE);
15
            for (int i = 0; i < hdr.length; i++) {
16
                cookieManager.addCookieFromHeader(hdr[i].getValue(),u);
17
            }
18
        }
19
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.375
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (int i = 0; i < hdr.length; i++)
    3
    for (int i = 0; i < hdr.length; i++)
    3
    for (Header hdr : hdrs)
    Differences
    Expression1Expression2Difference
    org.apache.commons.httpclient.Header[]org.apache.http.Header[]VARIABLE_TYPE_MISMATCH
    org.apache.commons.httpclient.Header[]org.apache.http.Header[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.commons.httpclient.Header[] of variable hdr does not match with type org.apache.http.Header[] of variable hdrs
    • Make classes org.apache.commons.httpclient.Header[] and org.apache.http.Header[] extend a common superclass
    Type org.apache.commons.httpclient.Header[] of variable hdr does not match with type org.apache.http.Header[] of variable hdrs
    • Make classes org.apache.commons.httpclient.Header[] and org.apache.http.Header[] extend a common superclass
    3
    for (Header hdr : hdrs)
                                                                                                                  
    4
    cookieManager.addCookieFromHeader(hdr.getValue(), u);
    Preondition Violations
    Unmatched statement cookieManager.addCookieFromHeader(hdr.getValue(),u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    cookieManager.addCookieFromHeader(hdr.getValue(), u);
    4
    cookieManager.addCookieFromHeader(hdr[i].getValue(), u);
    4
    cookieManager.addCookieFromHeader(hdr[i].getValue(), u);
    Preondition Violations
    Unmatched statement cookieManager.addCookieFromHeader(hdr[i].getValue(),u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                        
    Precondition Violations (5)
    Row Violation
    1Type org.apache.commons.httpclient.Header[] of variable hdr does not match with type org.apache.http.Header[] of variable hdrs
    2Type org.apache.commons.httpclient.Header[] of variable hdr does not match with type org.apache.http.Header[] of variable hdrs
    3Unmatched statement cookieManager.addCookieFromHeader(hdr.getValue(),u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement cookieManager.addCookieFromHeader(hdr[i].getValue(),u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variable i with type int , while Clone fragment #2 returns variable hdr with type org.apache.http.Header