Perl5Matcher localMatcher = JMeterUtils.getMatcher(); String expression = ".*" + headerName + ": (\\d*).*"; Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK); if(localMatcher.matches(requestHeaders, pattern)) { // The value is in the first group, group 0 is the whole match return localMatcher.getMatch().group(1); }
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);
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
Method name: String getSentRequestHeaderValue(String, String) Method name: String getRequestHeaderValue(String, String)
Number of AST nodes: 5 Number of AST nodes: 4
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
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
        String expression = ".*" + headerName + ": (\\d*).*";
5
        String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$        
3
        Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK);
6
        Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
4
        if(localMatcher.matches(requestHeaders, pattern)) {
7
        if(localMatcher.contains(requestHeaders, pattern)) {
5
            // The value is in the first group, group 0 is the whole match
8
            // The value is in the first group, group 0 is the whole match
6
            return localMatcher.getMatch().group(1);
9
            return localMatcher.getMatch().group(1);
7
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    2
    String expression = ".*" + headerName + ": (\\d*).*";
    2
    String expression = ".*" + headerName + ": (\\d*).*";
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    Differences
    Expression1Expression2Difference
    ": (\\d*).*"":\\s+(\\w+)"LITERAL_VALUE_MISMATCH
    ".*""^"LITERAL_VALUE_MISMATCH
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    Differences
    Expression1Expression2Difference
    SINGLELINE_MASKMULTILINE_MASKVARIABLE_NAME_MISMATCH
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables localMatcher, pattern , while Clone fragment #2 returns variables localMatcher, pattern