while ( iter.hasNext() ) { String prop = (String) iter.next(); if ( prop.indexOf(Environment.JNDI_PREFIX) > -1 && !specialProps.contains(prop) ) { result.setProperty( prop.substring( Environment.JNDI_PREFIX.length()+1 ), properties.getProperty(prop) ); } }
while ( iter.hasNext() ) { String prop = (String) iter.next(); if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop) ) { result.setProperty( prop.substring( Environment.CONNECTION_PREFIX.length()+1 ), properties.getProperty(prop) ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/NamingHelper.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
Method name: Properties getJndiProperties(Properties) Method name: Properties getConnectionProperties(Properties)
Number of AST nodes: 4 Number of AST nodes: 4
1
while ( iter.hasNext() ) {
1
while ( iter.hasNext() ) {
2
			String prop = (String) iter.next();
2
			String prop = (String) iter.next();
3
			if ( prop.indexOf(Environment.JNDI_PREFIX) > -1 && !specialProps.contains(prop) ) {
3
			if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop) ) {
4
				result.setProperty(
4
				result.setProperty(
5
						prop.substring( Environment.JNDI_PREFIX.length()+1 ),
5
					prop.substring( Environment.CONNECTION_PREFIX.length()+1 ),
6
						properties.getProperty(prop)
6
					properties.getProperty(prop)
7
					);
7
				);
8
			}
8
			}
9
		}
9
		}
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 in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    while (iter.hasNext())
    3
    while (iter.hasNext())
    7
    String prop = (String)iter.next();
    4
    String prop = (String)iter.next();
    8
    if (prop.indexOf(Environment.JNDI_PREFIX) > -1 && !specialProps.contains(prop))
    8
    if (prop.indexOf(Environment.JNDI_PREFIX) > -1 && !specialProps.contains(prop))
    5
    if (prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop))
    Differences
    Expression1Expression2Difference
    JNDI_PREFIXCONNECTION_PREFIXVARIABLE_NAME_MISMATCH
    specialPropsSPECIAL_PROPERTIESVARIABLE_NAME_MISMATCH
    java.util.HashSetjava.util.SetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.HashSet of variable specialProps does not match with type java.util.Set of variable SPECIAL_PROPERTIES
    • Make classes java.util.HashSet and java.util.Set extend a common superclass
    5
    if (prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop))
    9
    result.setProperty(prop.substring(Environment.JNDI_PREFIX.length() + 1), properties.getProperty(prop));
    9
    result.setProperty(prop.substring(Environment.JNDI_PREFIX.length() + 1), properties.getProperty(prop));
    6
    result.setProperty(prop.substring(Environment.CONNECTION_PREFIX.length() + 1), properties.getProperty(prop));
    Differences
    Expression1Expression2Difference
    JNDI_PREFIXCONNECTION_PREFIXVARIABLE_NAME_MISMATCH
    6
    result.setProperty(prop.substring(Environment.CONNECTION_PREFIX.length() + 1), properties.getProperty(prop));
    Precondition Violations (1)
    Row Violation
    1Type java.util.HashSet of variable specialProps does not match with type java.util.Set of variable SPECIAL_PROPERTIES