if (fileEntry.inputOutputObject == null) { fileEntry.inputOutputObject = createBufferedWriter(fileEntry, filename); } else if (!(fileEntry.inputOutputObject instanceof Writer)) { throw new IOException("File " + filename + " already in use"); } BufferedWriter writer = (BufferedWriter) fileEntry.inputOutputObject;
if (fileEntry.inputOutputObject == null) { fileEntry.inputOutputObject = createBufferedReader(fileEntry, filename); } else if (!(fileEntry.inputOutputObject instanceof Reader)) { throw new IOException("File " + filename + " already in use"); } BufferedReader reader = (BufferedReader) fileEntry.inputOutputObject;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/services/FileServer.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/services/FileServer.java
Method name: void write(String, String) Method name: String readLine(String, boolean)
Number of AST nodes: 5 Number of AST nodes: 5
1
if (fileEntry.inputOutputObject == null) {
1
if (fileEntry.inputOutputObject == null) {
2
				fileEntry.inputOutputObject = createBufferedWriter(fileEntry, filename);
2
				fileEntry.inputOutputObject = createBufferedReader(fileEntry, filename);
3
			} else if (!(fileEntry.inputOutputObject instanceof Writer)) {
3
            } else if (!(fileEntry.inputOutputObject instanceof Reader)) {
4
				throw new IOException("File " + filename + " already in use");
4
                throw new IOException("File " + filename + " already in use");
5
			}
5
            }
6
			BufferedWriter writer = (BufferedWriter) fileEntry.inputOutputObject;
6
			BufferedReader reader = (BufferedReader) fileEntry.inputOutputObject;
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.4
Clones locationClones are declared in the same class
Number of node comparisons15
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    if (fileEntry.inputOutputObject == null)
    3
    if (fileEntry.inputOutputObject == null)
                                                                                                                                                    
    4
    fileEntry.inputOutputObject = createBufferedReader(fileEntry, filename);
    Preondition Violations
    Unmatched statement fileEntry.inputOutputObject=createBufferedReader(fileEntry,filename); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    fileEntry.inputOutputObject = createBufferedReader(fileEntry, filename);
    4
    fileEntry.inputOutputObject = createBufferedWriter(fileEntry, filename);
    4
    fileEntry.inputOutputObject = createBufferedWriter(fileEntry, filename);
    Preondition Violations
    Unmatched statement fileEntry.inputOutputObject=createBufferedWriter(fileEntry,filename); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                    
    5
    else if (!(fileEntry.inputOutputObject instanceof Writer))
    5
    else if (!(fileEntry.inputOutputObject instanceof Writer))
    5
    else if (!(fileEntry.inputOutputObject instanceof Reader))
    Differences
    Expression1Expression2Difference
    java.io.Writerjava.io.ReaderVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression fileEntry.inputOutputObject instanceof Writer cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fileEntry.inputOutputObject instanceof Reader cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type boolean of variable fileEntry.inputOutputObject instanceof Writer does not match with type boolean of variable fileEntry.inputOutputObject instanceof Reader
    • Make classes java.io.Writer and java.io.Reader extend a common superclass
    5
    else if (!(fileEntry.inputOutputObject instanceof Reader))
    6
    throw new IOException("File " + filename + " already in use");
    6
    throw new IOException("File " + filename + " already in use");
                                                                                                                                              
    7
    BufferedReader reader = (BufferedReader)fileEntry.inputOutputObject;
    7
    BufferedWriter writer = (BufferedWriter)fileEntry.inputOutputObject;
                                                                                                                                              
    Precondition Violations (5)
    Row Violation
    1Unmatched statement fileEntry.inputOutputObject=createBufferedReader(fileEntry,filename); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement fileEntry.inputOutputObject=createBufferedWriter(fileEntry,filename); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression fileEntry.inputOutputObject instanceof Writer cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression fileEntry.inputOutputObject instanceof Reader cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Type boolean of variable fileEntry.inputOutputObject instanceof Writer does not match with type boolean of variable fileEntry.inputOutputObject instanceof Reader