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(); } }
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(); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/pop3/POP3Store.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/imap/IMAPServer.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.auth(AuthenticationManager
3
						protocol.authenticate(AuthenticationManager
4
								.getSaslName(loginMethod), popItem.get("user"),
4
								.getSaslName(loginMethod), item.get("user"),
5
								password);
5
								password);
6
						login
6
						// If no exception happened we have successfully logged
7
						// in
7
 = true;
8
						authenticated = true;
8
					} catch (AuthenticationException e) {
9
					} catch (AuthenticationException e) {
9
						// If the cause is a IMAPExcpetion then only password
10
						// If the cause is a IMAPExcpetion then only password
10
						// wrong
11
						// wrong
11
						// else bogus authentication mechanism
12
						// else bogus authentication mechanism
12
						if (e.getCause() instanceof POP3Exception)
13
						if (e.getCause() instanceof IMAPException)
13
							throw (POP3Exception) e.getCause();
14
							throw (IMAPException) e.getCause();
14
						// Some error in the client/server communication
15
						// Some error in the client/server communication
15
						// --> fall back to default login process
16
						// --> fall back to default login process
16
						int result = JOptionPane
17
						int result = JOptionPane
17
								.showConfirmDialog(
18
								.showConfirmDialog(
18
										FrameManager.getInstance()
19
										FrameManager.getInstance()
19
												.getActiveFrame(),
20
												.getActiveFrame(),
20
										new MultiLineLabel(
21
										new MultiLineLabel(
21
												e.getMessage()
22
												e.getMessage()
22
														+ "\n"
23
														+ "\n"
23
														+ MailResourceLoader
24
														+ MailResourceLoader
24
																.getString(
25
																.getString(
25
																		"dialog",
26
																		"dialog",
26
																		"error",
27
																		"error",
27
																		"authentication_fallback_to_default")),
28
																		"authentication_fallback_to_default")),
28
										MailResourceLoader.getString("dialog",
29
										MailResourceLoader.getString("dialog",
29
												"error",
30
												"error",
30
												"authentication_process_error"),
31
												"authentication_process_error"),
31
										JOptionPane.OK_CANCEL_OPTION);
32
										JOptionPane.OK_CANCEL_OPTION);
32
						if (result == JOptionPane.OK_OPTION) {
33
						if (result == JOptionPane.OK_OPTION) {
33
							loginMethod = AuthenticationManager.USER;
34
							loginMethod = AuthenticationManager.LOGIN;
34
							popItem.setString("login_method", Integer
35
							item.setString("login_method", Integer
35
									.toString(loginMethod));
36
									.toString(loginMethod));
36
						} else {
37
						} else {
37
							throw new CommandCancelledException();
38
							throw new CommandCancelledException();
38
						}
39
						}
39
					}
40
					}
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)1.4
Clones locationClones are in different classes
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    23
    try
    23
    try
    24
    try
    Differences
    Expression1Expression2Difference
    org.columba.ristretto.pop3.POP3Exceptionorg.columba.ristretto.imap.IMAPExceptionSUBCLASS_TYPE_MISMATCH
    org.columba.ristretto.pop3.POP3Exceptionorg.columba.ristretto.imap.IMAPExceptionSUBCLASS_TYPE_MISMATCH
    USERLOGINVARIABLE_NAME_MISMATCH
    popItemitemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.PopItemorg.columba.mail.config.ImapItemSUBCLASS_TYPE_MISMATCH
    24
    try
    24
    protocol.auth(AuthenticationManager.getSaslName(loginMethod), popItem.get("user"), password);
    24
    protocol.auth(AuthenticationManager.getSaslName(loginMethod), popItem.get("user"), password);
    Preondition Violations
    Unmatched statement protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password); 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
                                                                                                                                                                                                  
                                                                                                                                                                                                            
    25
    protocol.authenticate(AuthenticationManager.getSaslName(loginMethod), item.get("user"), password);
    Preondition Violations
    Unmatched statement protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password); 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
    25
    protocol.authenticate(AuthenticationManager.getSaslName(loginMethod), item.get("user"), password);
    25
    login = true;
    25
    login = true;
    26
    authenticated = true;
    Differences
    Expression1Expression2Difference
    loginauthenticatedVARIABLE_NAME_MISMATCH
    26
    authenticated = true;
    Precondition Violations (2)
    Row Violation
    1Unmatched statement protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password); 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 protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password); 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