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);
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);
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: BufferedReader createBufferedReader(FileEntry, String) Method name: BufferedWriter createBufferedWriter(FileEntry, String)
Number of AST nodes: 7 Number of AST nodes: 7
1
FileInputStream fis = new FileInputStream(fileEntry.file);				
1
FileOutputStream fos = new FileOutputStream(fileEntry.file);				
2
		InputStreamReader isr = null;
2
		OutputStreamWriter osw = null;
3
        // If file encoding is specified, read using that encoding, otherwise use default platform encoding
3
        // If file encoding is specified, write 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
			isr = new InputStreamReader(fis, charsetName); 
6
			osw = new OutputStreamWriter(fos, charsetName); 
7
		} else {
7
		} else {
8
			isr = new InputStreamReader(fis); 
8
			osw = new OutputStreamWriter(fos); 
9
		}
9
		}
10
		return new BufferedReader(isr);
10
		return new BufferedWriter(osw);
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.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                              
    1
    FileOutputStream fos = new FileOutputStream(fileEntry.file);
    1
    FileInputStream fis = new FileInputStream(fileEntry.file);
                                                                                                                          
                                                                  
    2
    OutputStreamWriter osw = null;
    2
    InputStreamReader isr = 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
    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
    5
    osw = new OutputStreamWriter(fos, charsetName);
    5
    isr = new InputStreamReader(fis, charsetName);
    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
                                                                                                
    else
            
                                                                          
    6
    osw = new OutputStreamWriter(fos);
    6
    isr = new InputStreamReader(fis);
                                                                        
                                                                        
    7
    return new BufferedWriter(osw);
    Preondition Violations
    Unmatched return new BufferedWriter(osw);
    7
    return new BufferedWriter(osw);
    7
    return new BufferedReader(isr);
    7
    return new BufferedReader(isr);
    Preondition Violations
    Unmatched return new BufferedReader(isr);
                                                                        
    Precondition Violations (4)
    Row Violation
    1Unmatched statement osw=new OutputStreamWriter(fos,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement isr=new InputStreamReader(fis,charsetName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched return new BufferedWriter(osw);
    4Unmatched return new BufferedReader(isr);