int count = 0; while (getProductVersion && count++ < iterations) { try { System.out.println("Thread "+Thread.currentThread().getName()); md.getDatabaseProductVersion(); if (sleepTime > 0) { Thread.sleep(sleepTime); } } catch (Exception e) { handleException(e); } }
int count = 0; while (getJDBCVersion && count++ < iterations) { try { System.out.println("Thread "+Thread.currentThread().getName()); md.getJDBCMajorVersion(); md.getJDBCMinorVersion(); if (sleepTime > 0) { Thread.sleep(sleepTime); } } catch (Exception e) { handleException(e); } }
Clone fragments detected by clone detection tool
File path: /sql12/test/adhoc/test/DBMetaDataConcurrencyTester.java File path: /sql12/test/adhoc/test/DBMetaDataConcurrencyTester.java
Method name: void run() Method name: void run()
Number of AST nodes: 7 Number of AST nodes: 8
1
int count = 0;
1
int count = 0;
2
            while (getProductVersion && count++ < iterations) {
2
            while (getJDBCVersion && count++ < iterations) {
3
                try {
3
                try {
4
                    System.out.println("Thread "+Thread.currentThread().getName());
4
                    System.out.println("Thread "+Thread.currentThread().getName());
5
                    md.getDatabaseProduct
5
                    md.getJDBCMajorVersion();
6
Version();
6
                    md.getJDBCMinorVersion();
7
                    if (sleepTime > 0) {
7
                    if (sleepTime > 0) {
8
                        Thread.sleep(sleepTime);
8
                        Thread.sleep(sleepTime);
9
                    }
9
                    }
10
                } catch (Exception e) {
10
                } catch (Exception e) {
11
                    handleException(e);
11
                    handleException(e);
12
                } 
12
                } 
13
            }
13
            }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in the same java file
Number of node comparisons18
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int count = 0;
    1
    int count = 0;
    2
    while (getProductVersion && count++ < iterations)
    2
    while (getProductVersion && count++ < iterations)
    2
    while (getJDBCVersion && count++ < iterations)
    Differences
    Expression1Expression2Difference
    getProductVersiongetJDBCVersionVARIABLE_NAME_MISMATCH
    2
    while (getJDBCVersion && count++ < iterations)
    3
    try
    3
    try
    4
    System.out.println("Thread " + Thread.currentThread().getName());
    4
    System.out.println("Thread " + Thread.currentThread().getName());
                                                            
    5
    md.getJDBCMajorVersion();
    Preondition Violations
    Unmatched statement md.getJDBCMajorVersion(); 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
    5
    md.getJDBCMajorVersion();
    5
    md.getDatabaseProductVersion();
    5
    md.getDatabaseProductVersion();
    Preondition Violations
    Unmatched statement md.getDatabaseProductVersion(); 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
                                                                        
                                                            
    6
    md.getJDBCMinorVersion();
    Preondition Violations
    Unmatched statement md.getJDBCMinorVersion(); 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
    6
    md.getJDBCMinorVersion();
    6
    if (sleepTime > 0)
    7
    if (sleepTime > 0)
    7
    Thread.sleep(sleepTime);
    8
    Thread.sleep(sleepTime);
    Precondition Violations (3)
    Row Violation
    1Unmatched statement md.getJDBCMajorVersion(); 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
    2Unmatched statement md.getDatabaseProductVersion(); 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
    3Unmatched statement md.getJDBCMinorVersion(); 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