if(channel != null) { try { channel.close(); } catch(IOException iex) { log.debug("Error closing channel",iex); } }
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/http/sampler/AjpSampler.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(channel != null) {
2
            try {
3
            channel.close();
4
            } catch(IO
1
while (itr.hasNext()) {
2
			Context ctx = (Context) MAP.get(itr.next());
3
			try {
4
				ctx.close();
5
Exception iex) {
5
			} catch (NamingException e) {
6
            log.debug("Error closing channel",iex);
7
            }
8
        
6
				log.error(e.getMessage());
7
			}
9
}
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.2
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)0.9
    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());
    2
    try
    2
    try
    4
    try
    Differences
    Expression1Expression2Difference
    java.io.IOExceptionjavax.naming.NamingExceptionSUBCLASS_TYPE_MISMATCH
    iexeVARIABLE_NAME_MISMATCH
    java.io.IOExceptionjavax.naming.NamingExceptionSUBCLASS_TYPE_MISMATCH
    debugerrorMETHOD_INVOCATION_NAME_MISMATCH
    log.debug("Error closing channel",iex)log.error(e.getMessage())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression log.debug("Error closing channel",iex) 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
    Expression log.debug("Error closing channel",iex) 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
    3
    channel.close();
    3
    channel.close();
    5
    ctx.close();
    Differences
    Expression1Expression2Difference
    channelctxVARIABLE_NAME_MISMATCH
    java.net.Socketjavax.naming.ContextVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.net.Socket of variable channel does not match with type javax.naming.Context of variable ctx
    • Make classes java.net.Socket and javax.naming.Context extend a common superclass
    5
    ctx.close();
    Precondition Violations (6)
    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 log.debug("Error closing channel",iex) 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
    4Expression log.debug("Error closing channel",iex) is a void method call, and thus it cannot be parameterized
    5Expression log.error(e.getMessage()) is a void method call, and thus it cannot be parameterized
    6Type java.net.Socket of variable channel does not match with type javax.naming.Context of variable ctx