FileOutputStream fos = new FileOutputStream(fileEntry.file); OutputStreamWriter osw = null; // If file encoding is specified, write using that encoding, otherwise use default platform encoding String charsetName = fileEntry.charSetEncoding; if(charsetName != null && charsetName.trim().length() > 0) { osw = new OutputStreamWriter(fos, charsetName); } else { osw = new OutputStreamWriter(fos); } return new BufferedWriter(osw);
FileInputStream fis = new FileInputStream(fileEntry.file); InputStreamReader isr = null; // If file encoding is specified, read using that encoding, otherwise use default platform encoding String charsetName = fileEntry.charSetEncoding; if(charsetName != null && charsetName.trim().length() > 0) { isr = new InputStreamReader(fis, charsetName); } else { isr = new InputStreamReader(fis); } return new BufferedReader(isr);
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: BufferedWriter createBufferedWriter(FileEntry, String) Method name: BufferedReader createBufferedReader(FileEntry, String)
Number of AST nodes: 7 Number of AST nodes: 7
1
FileOutputStream fos = new FileOutputStream(fileEntry.file);				
1
FileInputStream fis = new FileInputStream(fileEntry.file);				
2
		OutputStreamWriter osw = null;
2
		InputStreamReader isr = null;
3
        // If file encoding is specified, write using that encoding, otherwise use default platform encoding
3
        // If file encoding is specified, read using that encoding, otherwise use default platform encoding
4
		String charsetName = fileEntry.charSetEncoding;
4
		String charsetName = fileEntry.charSetEncoding;
5
		if(charsetName != null && charsetName.trim().length() > 0) {
5
		if(charsetName != null && charsetName.trim().length() > 0) {
6
			osw = new OutputStreamWriter(fos, charsetName); 
6
			isr = new InputStreamReader(fis, charsetName); 
7
		} else {
7
		} else {
8
			osw = new OutputStreamWriter(fos); 
8
			isr = new InputStreamReader(fis); 
9
		}
9
		}
10
		return new BufferedWriter(osw);
10
		return new BufferedReader(isr);
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.3
Clones locationClones are declared in the same class
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                          
    1
    FileInputStream fis = new FileInputStream(fileEntry.file);
    1
    FileOutputStream fos = new FileOutputStream(fileEntry.file);
                                                                                                                              
                                                                
    2
    InputStreamReader isr = null;
    2
    OutputStreamWriter osw = null;
                                                                  
    3
    String charsetName = fileEntry.charSetEncoding;
    3
    String charsetName = fileEntry.charSetEncoding;
    4
    if (charsetName != null && charsetName.trim().length() > 0)
    4
    if (charsetName != null && charsetName.trim().length() > 0)
                                                                                                
    5
    isr = new InputStreamReader(fis, charsetName);
    Preondition Violations
    Unmatched statement isr=new InputStreamReader(fis,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    isr = new InputStreamReader(fis, charsetName);
    5
    osw = new OutputStreamWriter(fos, charsetName);
    5
    osw = new OutputStreamWriter(fos, charsetName);
    Preondition Violations
    Unmatched statement osw=new OutputStreamWriter(fos,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                  
    else
            
                                                                        
    6
    isr = new InputStreamReader(fis);
    6
    osw = new OutputStreamWriter(fos);
                                                                          
                                                                        
    7
    return new BufferedReader(isr);
    Preondition Violations
    Unmatched return new BufferedReader(isr);
    7
    return new BufferedReader(isr);
    7
    return new BufferedWriter(osw);
    7
    return new BufferedWriter(osw);
    Preondition Violations
    Unmatched return new BufferedWriter(osw);
                                                                        
    Precondition Violations (4)
    Row Violation
    1Unmatched statement isr=new InputStreamReader(fis,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement osw=new OutputStreamWriter(fos,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched return new BufferedReader(isr);
    4Unmatched return new BufferedWriter(osw);