Perl5Matcher localMatcher = JMeterUtils.getMatcher(); // The headers and body are divided by a blank line String regularExpression = "^.$"; Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); PatternMatcherInput input = new PatternMatcherInput(stringToCheck); while(localMatcher.contains(input, pattern)) { MatchResult match = localMatcher.getMatch(); return match.beginOffset(0); } // No divider was found return -1;
Perl5Matcher localMatcher = JMeterUtils.getMatcher(); // The headers and body are divided by a blank line (the \r is to allow for the CR before LF) String regularExpression = "^\\r$"; // $NON-NLS-1$ Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); PatternMatcherInput input = new PatternMatcherInput(stringToCheck); if(localMatcher.contains(input, pattern)) { MatchResult match = localMatcher.getMatch(); return match.beginOffset(0); } // No divider was found return -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: int getPositionOfBody(String) Method name: int getPositionOfBody(String)
Number of AST nodes: 8 Number of AST nodes: 8
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
2
        // The headers and body are divided by a blank line
2
        // The headers and body are divided by a blank line (the \r is to allow for the CR before LF)
3
        String regularExpression = "^.$"; 
3
        String regularExpression = "^\\r$"; // $NON-NLS-1$
4
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
4
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
5
        
5
        
6
        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
6
        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
7
        while(localMatcher.contains(input, pattern)) {
7
        if(localMatcher.contains(input, pattern)) {
8
            MatchResult match = localMatcher.getMatch();
8
            MatchResult match = localMatcher.getMatch();
9
            return match.beginOffset(0);
9
            return match.beginOffset(0);
10
        }
10
        }
11
        // No divider was found
11
        // No divider was found
12
        return -1;
12
        return -1;
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.1
Clones locationClones are in different classes
Number of node comparisons18
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)2.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    2
    String regularExpression = "^.$";
    2
    String regularExpression = "^.$";
    2
    String regularExpression = "^\\r$";
    Differences
    Expression1Expression2Difference
    "^.$""^\\r$"LITERAL_VALUE_MISMATCH
    2
    String regularExpression = "^\\r$";
    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);
    4
    PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
    4
    PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
                                                                                          
    5
    if (localMatcher.contains(input, pattern))
    Preondition Violations
    Unmatched statement if(localMatcher.contains(input,pattern)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    if (localMatcher.contains(input, pattern))
                                                                                              
    6
    MatchResult match = localMatcher.getMatch();
    Preondition Violations
    Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    MatchResult match = localMatcher.getMatch();
                                                                  
    7
    return match.beginOffset(0);
    Preondition Violations
    Unmatched return match.beginOffset(0);
    7
    return match.beginOffset(0);
    5
    while (localMatcher.contains(input, pattern))
    5
    while (localMatcher.contains(input, pattern))
    Preondition Violations
    Unmatched statement while(localMatcher.contains(input,pattern)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
    6
    MatchResult match = localMatcher.getMatch();
    6
    MatchResult match = localMatcher.getMatch();
    Preondition Violations
    Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    7
    return match.beginOffset(0);
    7
    return match.beginOffset(0);
    Preondition Violations
    Unmatched return match.beginOffset(0);
                                                                  
    8
    return -1;
    8
    return -1;
    Precondition Violations (8)
    Row Violation
    1Unmatched statement if(localMatcher.contains(input,pattern)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched return match.beginOffset(0);
    4Unmatched statement while(localMatcher.contains(input,pattern)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched return match.beginOffset(0);
    7Clone fragment #1 returns variables localMatcher, pattern, input , while Clone fragment #2 returns variables localMatcher, pattern, input
    8The refactoring of the clones is infeasible, because classes org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer and org.apache.jmeter.protocol.http.control.HttpMirrorThread do not have a common superclass