File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java | |||
Method name: void waitForString(String, Integer)
|
Method name: void waitForString(String, Integer)
|
|||
Number of AST nodes: 16 | Number of AST nodes: 15 | |||
1 | InputStream is = this.getInputStream();↵ | 1 | InputStream is = this.getInputStream();↵ | |
2 | try {↵ | 2 | try {↵ | |
3 | StringBuffer sb = new StringBuffer();↵ | 3 | StringBuffer sb = new StringBuffer();↵ | |
4 | if (timeout == null || timeout.intValue() == 0) {↵ | 4 | if (timeout == null || timeout.intValue() == 0) {↵ | |
5 | while (sb.toString().indexOf(s) == -1) {↵ | 5 | while (sb.toString().indexOf(s) == -1) {↵ | |
6 | sb.append((char) is.read());↵ | 6 | sb.append((char) is.read());↵ | |
7 | }↵ | 7 | }↵ | |
8 | } else {↵ | 8 | } else {↵ | |
9 | Calendar endTime = Calendar.getInstance();↵ | 9 | Calendar endTime = Calendar.getInstance();↵ | |
10 | endTime.add(Calendar.SECOND, timeout.intValue());↵ | 10 | endTime.add(Calendar.SECOND, timeout.intValue());↵ | |
11 | while (sb.toString().indexOf(s) == -1) {↵ | 11 | while (sb.toString().indexOf(s) == -1) {↵ | |
12 | while (Calendar.getInstance().before(endTime)↵ | 12 | while (Calendar.getInstance().before(endTime)↵ | |
13 | && is.available() == 0) {↵ | 13 | && is.available() == 0) {↵ | |
14 | Thread.sleep(250);↵ | 14 | Thread.sleep(250);↵ | |
15 | }↵ | 15 | }↵ | |
16 | if (is.available() == 0) {↵ | 16 | if (is.available() == 0) {↵ | |
17 | log("Read before running into timeout: "↵ | |||
18 | + sb.toString(), Project.MSG_DEBUG);↵ | |||
19 | throw new BuildException(↵ | 17 | throw new BuildException(↵ | |
20 | "Response timed-out waiting for \"" + s + '\"',↵ | 18 | "Response timed-out waiting for \"" + s + '\"',↵ | |
21 | getLocation());↵ | 19 | getLocation());↵ | |
22 | }↵ | 20 | }↵ | |
23 | sb.append((char) is.read());↵ | 21 | sb.append((char) is.read());↵ | |
24 | }↵ | 22 | }↵ | |
25 | }↵ | 23 | }↵ | |
26 | log(sb.toString(), Project.MSG_INFO);↵ | 24 | log(sb.toString(), Project.MSG_INFO);↵ | |
27 | } catch (BuildException be) {↵ | 25 | } catch (BuildException be) {↵ | |
28 | throw be;↵ | 26 | throw be;↵ | |
29 | } catch (Exception e) {↵ | 27 | } catch (Exception e) {↵ | |
30 | throw new BuildException(e, getLocation());↵ | 28 | throw new BuildException(e, getLocation());↵ | |
31 | } | 29 |
| |
See real code fragment | See real code fragment |
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) | 2.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 46 |
Number of mapped statements | 15 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 4.3 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | InputStream is = this.getInputStream(); | 1 | InputStream is = this.getInputStream(); | ||||
2 | try | 2 | try | ||||
3 | StringBuffer sb = new StringBuffer(); | 3 | StringBuffer sb = new StringBuffer(); | ||||
4 | if (timeout == null || timeout.intValue() == 0) | 4 | if (timeout == null || timeout.intValue() == 0) | ||||
5 | while (sb.toString().indexOf(s) == -1) | 5 | while (sb.toString().indexOf(s) == -1) | ||||
6 | sb.append((char)is.read()); | 6 | sb.append((char)is.read()); | ||||
else | else | ||||||
7 | Calendar endTime = Calendar.getInstance(); | 7 | Calendar endTime = Calendar.getInstance(); | ||||
8 | endTime.add(Calendar.SECOND, timeout.intValue()); | 8 | endTime.add(Calendar.SECOND, timeout.intValue()); | ||||
9 | while (sb.toString().indexOf(s) == -1) | 9 | while (sb.toString().indexOf(s) == -1) | ||||
10 | while (Calendar.getInstance().before(endTime) && is.available() == 0) | 10 | while (Calendar.getInstance().before(endTime) && is.available() == 0) | ||||
11 | Thread.sleep(250); | 11 | Thread.sleep(250); | ||||
12 | if (is.available() == 0) | 12 | if (is.available() == 0) | ||||
13 | log("Read before running into timeout: " + sb.toString(), Project.MSG_DEBUG); |
| | ||||
14 | throw new BuildException("Response timed-out waiting for \"" + s + '\"', getLocation()); | 13 | throw new BuildException("Response timed-out waiting for \"" + s + '\"', getLocation()); | ||||
15 | sb.append((char)is.read()); | 14 | sb.append((char)is.read()); | ||||
16 | log(sb.toString(), Project.MSG_INFO); | 15 | log(sb.toString(), Project.MSG_INFO); |
Row | Violation |
---|---|
1 | Unmatched statement log("Read before running into timeout: " + sb.toString(),Project.MSG_DEBUG); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Clone fragment #1 returns variables sb , while Clone fragment #2 returns variables |