try { // AUTH protocol.authenticate(AuthenticationManager .getSaslName(loginMethod), item.get("user"), password); // If no exception happened we have successfully logged // in authenticated = true; } catch (AuthenticationException e) { // If the cause is a IMAPExcpetion then only password // wrong // else bogus authentication mechanism if (e.getCause() instanceof IMAPException) throw (IMAPException) e.getCause(); // Some error in the client/server communication // --> fall back to default login process int result = JOptionPane .showConfirmDialog( FrameManager.getInstance() .getActiveFrame(), new MultiLineLabel( e.getMessage() + "\n" + MailResourceLoader .getString( "dialog", "error", "authentication_fallback_to_default")), MailResourceLoader.getString("dialog", "error", "authentication_process_error"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { loginMethod = AuthenticationManager.LOGIN; item.setString("login_method", Integer .toString(loginMethod)); } else { throw new CommandCancelledException(); } }
try { // AUTH protocol.auth(AuthenticationManager .getSaslName(loginMethod), popItem.get("user"), password); login = true; } catch (AuthenticationException e) { // If the cause is a IMAPExcpetion then only password // wrong // else bogus authentication mechanism if (e.getCause() instanceof POP3Exception) throw (POP3Exception) e.getCause(); // Some error in the client/server communication // --> fall back to default login process int result = JOptionPane .showConfirmDialog( FrameManager.getInstance() .getActiveFrame(), new MultiLineLabel( e.getMessage() + "\n" + MailResourceLoader .getString( "dialog", "error", "authentication_fallback_to_default")), MailResourceLoader.getString("dialog", "error", "authentication_process_error"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { loginMethod = AuthenticationManager.USER; popItem.setString("login_method", Integer .toString(loginMethod)); } else { throw new CommandCancelledException(); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/imap/IMAPServer.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/pop3/POP3Store.java
Method name: void login() Method name: void login()
Number of AST nodes: 3 Number of AST nodes: 3
1
try {
1
try {
2
						// AUTH
2
						// AUTH
3
						protocol.authenticate(AuthenticationManager
3
						protocol.auth(AuthenticationManager
4
								.getSaslName(loginMethod), item.get("user"),
4
								.getSaslName(loginMethod), popItem.get("user"),
5
								password);
5
								password);
6
						// If no exception happened we have successfully logged
6
						
7
						// in
8
						authenticated = true;
7
login = true;
9
					} catch (AuthenticationException e) {
8
					} catch (AuthenticationException e) {
10
						// If the cause is a IMAPExcpetion then only password
9
						// If the cause is a IMAPExcpetion then only password
11
						// wrong
10
						// wrong
12
						// else bogus authentication mechanism
11
						// else bogus authentication mechanism
13
						if (e.getCause() instanceof IMAPException)
12
						if (e.getCause() instanceof POP3Exception)
14
							throw (IMAPException) e.getCause();
13
							throw (POP3Exception) e.getCause();
15
						// Some error in the client/server communication
14
						// Some error in the client/server communication
16
						// --> fall back to default login process
15
						// --> fall back to default login process
17
						int result = JOptionPane
16
						int result = JOptionPane
18
								.showConfirmDialog(
17
								.showConfirmDialog(
19
										FrameManager.getInstance()
18
										FrameManager.getInstance()
20
												.getActiveFrame(),
19
												.getActiveFrame(),
21
										new MultiLineLabel(
20
										new MultiLineLabel(
22
												e.getMessage()
21
												e.getMessage()
23
														+ "\n"
22
														+ "\n"
24
														+ MailResourceLoader
23
														+ MailResourceLoader
25
																.getString(
24
																.getString(
26
																		"dialog",
25
																		"dialog",
27
																		"error",
26
																		"error",
28
																		"authentication_fallback_to_default")),
27
																		"authentication_fallback_to_default")),
29
										MailResourceLoader.getString("dialog",
28
										MailResourceLoader.getString("dialog",
30
												"error",
29
												"error",
31
												"authentication_process_error"),
30
												"authentication_process_error"),
32
										JOptionPane.OK_CANCEL_OPTION);
31
										JOptionPane.OK_CANCEL_OPTION);
33
						if (result == JOptionPane.OK_OPTION) {
32
						if (result == JOptionPane.OK_OPTION) {
34
							loginMethod = AuthenticationManager.LOGIN;
33
							loginMethod = AuthenticationManager.USER;
35
							item.setString("login_method", Integer
34
							popItem.setString("login_method", Integer
36
									.toString(loginMethod));
35
									.toString(loginMethod));
37
						} else {
36
						} else {
38
							throw new CommandCancelledException();
37
							throw new CommandCancelledException();
39
						}
38
						}
40
					}
39
					}
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)2.6
Clones locationClones are in different classes
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)14.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    24
    try
    24
    try
    23
    try
    Differences
    Expression1Expression2Difference
    org.columba.ristretto.imap.IMAPExceptionorg.columba.ristretto.pop3.POP3ExceptionSUBCLASS_TYPE_MISMATCH
    org.columba.ristretto.imap.IMAPExceptionorg.columba.ristretto.pop3.POP3ExceptionSUBCLASS_TYPE_MISMATCH
    LOGINUSERVARIABLE_NAME_MISMATCH
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression e.getCause() instanceof IMAPException cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.getCause() instanceof POP3Exception cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IMAPException)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (POP3Exception)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23
    try
    25
    protocol.authenticate(AuthenticationManager.getSaslName(loginMethod), item.get("user"), password);
    25
    protocol.authenticate(AuthenticationManager.getSaslName(loginMethod), item.get("user"), password);
    24
    protocol.auth(AuthenticationManager.getSaslName(loginMethod), popItem.get("user"), password);
    Differences
    Expression1Expression2Difference
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    authenticateauthMETHOD_INVOCATION_NAME_MISMATCH
    org.columba.ristretto.imap.IMAPProtocolorg.columba.ristretto.pop3.POP3ProtocolSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) is a void method call, and thus it cannot be parameterized
    Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) is a void method call, and thus it cannot be parameterized
    Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void authenticate(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.imap.IMAPException, org.columba.ristretto.auth.AuthenticationException, public void auth(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.pop3.POP3Exception, org.columba.ristretto.auth.AuthenticationException
    24
    protocol.auth(AuthenticationManager.getSaslName(loginMethod), popItem.get("user"), password);
    26
    authenticated = true;
    26
    authenticated = true;
    25
    login = true;
    Differences
    Expression1Expression2Difference
    authenticatedloginVARIABLE_NAME_MISMATCH
    25
    login = true;
    Precondition Violations (9)
    Row Violation
    1Expression e.getCause() instanceof IMAPException cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression e.getCause() instanceof POP3Exception cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (IMAPException)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (POP3Exception)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    6Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    7Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) is a void method call, and thus it cannot be parameterized
    8Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) is a void method call, and thus it cannot be parameterized
    9Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void authenticate(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.imap.IMAPException, org.columba.ristretto.auth.AuthenticationException, public void auth(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.pop3.POP3Exception, org.columba.ristretto.auth.AuthenticationException