String val = getStringValue();
if (val == null) {
return 0;
}
try {
return Double.parseDouble(val);
} catch (NumberFormatException e) {
log.error("Tried to parse a non-number string to an integer", e);
return 0;
}
String val = getStringValue();
if (val == null) {
return 0;
}
try {
return Float.parseFloat(val);
} catch (NumberFormatException e) {
log.error("Tried to parse a non-number string to an integer", e);
return 0;
}
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/testelement/property/AbstractProperty.java
|
|
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/testelement/property/AbstractProperty.java
|
Method name: double getDoubleValue()
|
|
Method name: float getFloatValue()
|
Number of AST nodes: 5
|
|
Number of AST nodes: 5
|
|
1 | String val = getStringValue();↵ | | 1 | String val = getStringValue();↵
|
2 | if (val == null) {↵ | | 2 | if (val == null) {↵
|
3 | return 0;↵ | | 3 | return 0;↵
|
4 | }↵ | | 4 | }↵
|
5 | try {↵ | | 5 | try {↵
|
6 | return Double.parseDouble(val);↵ | | 6 | return Float.parseFloat(val);↵
|
7 | } catch (NumberFormatException e) {↵ | | 7 | } catch (NumberFormatException e) {↵
|
8 | log.error("Tried to parse a non-number string to an integer", e);↵ | | 8 | log.error("Tried to parse a non-number string to an integer", e);↵
|
9 | return 0;↵ | | 9 | return 0;↵
|
10 | } | | 10 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 14 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.6 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | String val = getStringValue(); | | 1 | String val = getStringValue(); |
2 | if (val == null) | | 2 | if (val == null) |
3 | | | 3 | |
4 | try | | 4 | try |
| | | 5 | return Float.parseFloat(val); |
5 | return Double.parseDouble(val); | | | |
Precondition Violations (2)
Row |
Violation |
1 | Unmatched statement return Float.parseFloat(val); 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 |
2 | Unmatched statement return Double.parseDouble(val); 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 |