String str = url; // chop to "server.name:x/thing" int i = str.indexOf("//"); if (i > 0) { str = str.substring(i + 2); } // chop to server.name:xx i = str.indexOf("/"); if (0 < i) { str = str.substring(0, i); } // chop XX i = str.indexOf(":"); if (0 < i) { return Integer.parseInt(str.substring(i + 1).trim()); } return HTTPSamplerBase.UNSPECIFIED_PORT;
String str = url; int i = str.indexOf("//"); // $NON-NLS-1$ if (i > 0) { str = str.substring(i + 2); } // chop to server.name:xx i = str.indexOf("/"); // $NON-NLS-1$ if (0 < i) { str = str.substring(0, i); } // chop to server.name i = str.indexOf(":"); // $NON-NLS-1$ if (0 < i) { str = str.substring(0, i); } return str;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
Method name: int serverPort() Method name: String serverName()
Number of AST nodes: 11 Number of AST nodes: 11
1
String str = url;
1
String str = url;
2
		// chop to "server.name:x/thing"
2
		
3
		int i = str.indexOf("//");
3
int i = str.indexOf("//"); // $NON-NLS-1$
4
		if (i > 0) {
4
		if (i > 0) {
5
			str = str.substring(i + 2);
5
			str = str.substring(i + 2);
6
		}
6
		}
7
		// chop to server.name:xx
7
		// chop to server.name:xx
8
		i = str.indexOf("/");
8
		i = str.indexOf("/"); // $NON-NLS-1$
9
		if (0 < i) {
9
		if (0 < i) {
10
			str = str.substring(0, i);
10
			str = str.substring(0, i);
11
		}
11
		}
12
		// chop XX
12
		// chop to server.name
13
		i = str.indexOf(":");
13
		i = str.indexOf(":"); // $NON-NLS-1$
14
		if (0 < i) {
14
		if (0 < i) {
15
			return Integer.parseInt(str.substring(i + 1).trim());
15
			str = str.substring(0, i);
16
		}
16
		}
17
		return HTTPSamplerBase.UNSPECIFIED_PORT;
17
		return str;
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.6
Clones locationClones are declared in the same class
Number of node comparisons46
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String str = url;
    1
    String str = url;
    2
    int i = str.indexOf("//");
    2
    int i = str.indexOf("//");
    3
    if (i > 0)
    3
    if (i > 0)
    4
    str = str.substring(i + 2);
    4
    str = str.substring(i + 2);
    5
    i = str.indexOf("/");
    5
    i = str.indexOf("/");
    6
    if (0 < i)
    6
    if (0 < i)
    7
    str = str.substring(0, i);
    7
    str = str.substring(0, i);
    8
    i = str.indexOf(":");
    8
    i = str.indexOf(":");
    9
    if (0 < i)
    9
    if (0 < i)
                                                          
    10
    str = str.substring(0, i);
    Preondition Violations
    Unmatched statement str=str.substring(0,i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    str = str.substring(0, i);
    10
    return Integer.parseInt(str.substring(i + 1).trim());
    10
    return Integer.parseInt(str.substring(i + 1).trim());
    Preondition Violations
    Unmatched statement return Integer.parseInt(str.substring(i + 1).trim()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement return Integer.parseInt(str.substring(i + 1).trim()); 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
    Unmatched return Integer.parseInt(str.substring(i + 1).trim());
                                                                                                                      
                                  
    11
    return str;
    Preondition Violations
    Unmatched statement return str; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return str;
    11
    return str;
    11
    return HTTPSamplerBase.UNSPECIFIED_PORT;
    11
    return HTTPSamplerBase.UNSPECIFIED_PORT;
    Preondition Violations
    Unmatched return HTTPSamplerBase.UNSPECIFIED_PORT;
                                                                                            
    Precondition Violations (8)
    Row Violation
    1Unmatched statement str=str.substring(0,i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement return Integer.parseInt(str.substring(i + 1).trim()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement return Integer.parseInt(str.substring(i + 1).trim()); 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
    4Unmatched return Integer.parseInt(str.substring(i + 1).trim());
    5Unmatched statement return str; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched return str;
    7Unmatched return HTTPSamplerBase.UNSPECIFIED_PORT;
    8Clone fragment #1 returns variables str, i , while Clone fragment #2 returns variables str, i