String regularExpression = headerName + "\\s*:\\s*(.*)$"; //$NON-NLS-1$ Perl5Matcher localMatcher = JMeterUtils.getMatcher(); Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); if(localMatcher.contains(multiPart, pattern)) { return localMatcher.getMatch().group(1).trim(); } else { return null; }
Perl5Matcher localMatcher = JMeterUtils.getMatcher(); // We use multi-line mask so can prefix the line with ^ // also match \w+ to catch Transfer-Encoding: chunked // TODO: may need to be extended to allow for other header values with non-word contents String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$ Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); if(localMatcher.contains(requestHeaders, pattern)) { // The value is in the first group, group 0 is the whole match return localMatcher.getMatch().group(1); } else { return null; }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
Method name: String getHeaderValue(String, String) Method name: String getRequestHeaderValue(String, String)
Number of AST nodes: 6 Number of AST nodes: 6
1
String regularE
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
2
        // We use multi-line mask so can prefix the line with ^
3
        // also match \w+ to catch Transfer-Encoding: chunked
4
        // TODO: may need to be extended to allow for other header values with non-word contents
2
xpression = headerName + "\\s*:\\s*(.*)$"; //$NON-NLS-1$
5
        String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$
3
        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
6
 $NON-NLS-2$        
4
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
7
        Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
5
        if(localMatcher.contains(multiPart, pattern)) {
8
        if(localMatcher.contains(requestHeaders, pattern)) {
9
            // The value is in the first group, group 0 is the whole match
6
            return localMatcher.getMatch().group(1).trim();
10
            return localMatcher.getMatch().group(1);
7
        }
11
        }
8
        else {
12
        else {
9
            return null;
13
            return null;
10
        }
14
        }
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 in different classes
Number of node comparisons18
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String regularExpression = headerName + "\\s*:\\s*(.*)$";
    1
    String regularExpression = headerName + "\\s*:\\s*(.*)$";
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    Differences
    Expression1Expression2Difference
    regularExpressionexpressionVARIABLE_NAME_MISMATCH
    headerName"^"TYPE_COMPATIBLE_REPLACEMENT
    "\\s*:\\s*(.*)$"headerNameTYPE_COMPATIBLE_REPLACEMENT
    headerName + "\\s*:\\s*(.*)$""^" + headerName + ":\\s+(\\w+)"INFIX_EXTENDED_OPERAND_NUMBER_MISMATCH
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    2
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    3
    Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    Differences
    Expression1Expression2Difference
    regularExpressionexpressionVARIABLE_NAME_MISMATCH
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    4
    if (localMatcher.contains(multiPart, pattern))
    4
    if (localMatcher.contains(multiPart, pattern))
    4
    if (localMatcher.contains(requestHeaders, pattern))
    Differences
    Expression1Expression2Difference
    multiPartrequestHeadersVARIABLE_NAME_MISMATCH
    4
    if (localMatcher.contains(requestHeaders, pattern))
                                                                                          
    5
    return localMatcher.getMatch().group(1);
    5
    return localMatcher.getMatch().group(1).trim();
                                                                                                        
    else
    else
    6
    return null;
    6
    return null;
    Precondition Violations (0)
    Row Violation