if (connection != null) { try { connection.close(); } catch (JMSException e) { LOGGER.info(e.getLocalizedMessage()); } }
while (itr.hasNext()) { Context ctx = (Context) MAP.get(itr.next()); try { ctx.close(); } catch (NamingException e) { log.error(e.getMessage()); } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/jms/client/InitialContextFactory.java
Method name: void threadFinished() Method name: void close()
Number of AST nodes: 3 Number of AST nodes: 4
1
if (connection != null) {
1
while (itr.hasNext()) {
2
			Context ctx = (Context) MAP.get(itr.next());
2
			try {
3
			try {
3
				connection.close();
4
				ctx.close();
4
			} catch (JMSException e) {
5
			} catch (NamingException e) {
5
				LOGGER.info(e.getLocalizedMessage());
6
				log.error(e.getMessage());
6
			}
7
			}
7
		}
8
		}
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 in different classes
Number of node comparisons5
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    3
    Context ctx = (Context)MAP.get(itr.next());
    Preondition Violations
    Unmatched statement Context ctx=(Context)MAP.get(itr.next()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    Context ctx = (Context)MAP.get(itr.next());
    6
    try
    6
    try
    4
    try
    Differences
    Expression1Expression2Difference
    javax.jms.JMSExceptionjavax.naming.NamingExceptionSUBCLASS_TYPE_MISMATCH
    javax.jms.JMSExceptionjavax.naming.NamingExceptionSUBCLASS_TYPE_MISMATCH
    infoerrorMETHOD_INVOCATION_NAME_MISMATCH
    getLocalizedMessagegetMessageMETHOD_INVOCATION_NAME_MISMATCH
    javax.jms.JMSExceptionjavax.naming.NamingExceptionSUBCLASS_TYPE_MISMATCH
    LOGGERlogVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression LOGGER.info(e.getLocalizedMessage()) is a void method call, and thus it cannot be parameterized
    Expression log.error(e.getMessage()) is a void method call, and thus it cannot be parameterized
    4
    try
    7
    connection.close();
    7
    connection.close();
    5
    ctx.close();
    Differences
    Expression1Expression2Difference
    connectionctxVARIABLE_NAME_MISMATCH
    javax.jms.QueueConnectionjavax.naming.ContextVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type javax.jms.QueueConnection of variable connection does not match with type javax.naming.Context of variable ctx
    • Make classes javax.jms.QueueConnection and javax.naming.Context extend a common superclass
    5
    ctx.close();
    Precondition Violations (4)
    Row Violation
    1Unmatched statement Context ctx=(Context)MAP.get(itr.next()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression LOGGER.info(e.getLocalizedMessage()) is a void method call, and thus it cannot be parameterized
    3Expression log.error(e.getMessage()) is a void method call, and thus it cannot be parameterized
    4Type javax.jms.QueueConnection of variable connection does not match with type javax.naming.Context of variable ctx