if ((cachefile != null) && cache.propertyNames().hasMoreElements()) { try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(cachefile)); cache.store(bos, null); bos.flush(); bos.close(); } catch (Exception e) { e.printStackTrace(); } }
if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) { try { BufferedInputStream bis = new BufferedInputStream( new FileInputStream(cachefile)); cache.load(bis); bis.close(); } catch (Exception e) { e.printStackTrace(); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java
Method name: void save() Method name: void load()
Number of AST nodes: 6 Number of AST nodes: 5
1
if ((cachefile != null) && cache.propertyNames().hasMoreElements()) {
1
if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) {
2
            try {
2
            try {
3
                BufferedOutputStream bos = new BufferedOutputStream(
3
                BufferedInputStream bis = new BufferedInputStream(
4
                      new FileOutputStream(cachefile));
4
                    new FileInputStream(cachefile));
5
                cache.store(bos, null);
5
                cache.
6
                bos.flush();
6
load(bis);
7
                bos.close();
7
                bis.close();
8
            } catch (Exception e) {
8
            } catch (Exception e) {
9
                e.printStackTrace();
9
                e.printStackTrace();
10
            }
10
            }
11
        }
11
        }
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 comparisons21
  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 fragment1
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    try
    2
    try
                                                                                                                                                                          
    3
    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(cachefile));
    5
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(cachefile));
                                                                                                                                                                                
    6
    cache.store(bos, null);
    6
    cache.store(bos, null);
    4
    cache.load(bis);
    Differences
    Expression1Expression2Difference
    storeloadMETHOD_INVOCATION_NAME_MISMATCH
    cache.store(bos,null)cache.load(bis)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression cache.store(bos,null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression cache.load(bis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression cache.store(bos,null) is a void method call, and thus it cannot be parameterized
    Expression cache.load(bis) is a void method call, and thus it cannot be parameterized
    Expression cache.store(bos,null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression cache.load(bis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression cache.store(bos,null) is a void method call, and thus it cannot be parameterized
    Expression cache.load(bis) is a void method call, and thus it cannot be parameterized
    4
    cache.load(bis);
    7
    bos.flush();
    7
    bos.flush();
    Preondition Violations
    Unmatched statement bos.flush(); 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
                                  
    8
    bos.close();
    8
    bos.close();
    5
    bis.close();
    Differences
    Expression1Expression2Difference
    bosbisVARIABLE_NAME_MISMATCH
    java.io.BufferedOutputStreamjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedOutputStream of variable bos does not match with type java.io.BufferedInputStream of variable bis
    • Make classes java.io.BufferedOutputStream and java.io.BufferedInputStream extend a common superclass
    5
    bis.close();
    Precondition Violations (10)
    Row Violation
    1Expression cache.store(bos,null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    2Expression cache.load(bis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3Expression cache.store(bos,null) is a void method call, and thus it cannot be parameterized
    4Expression cache.load(bis) is a void method call, and thus it cannot be parameterized
    5Expression cache.store(bos,null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    6Expression cache.load(bis) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    7Expression cache.store(bos,null) is a void method call, and thus it cannot be parameterized
    8Expression cache.load(bis) is a void method call, and thus it cannot be parameterized
    9Unmatched statement bos.flush(); 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
    10Type java.io.BufferedOutputStream of variable bos does not match with type java.io.BufferedInputStream of variable bis