int sslType = item.getIntegerWithDefault("ssl_type", IncomingItem.TLS); boolean sslEnabled = item.getBoolean("enable_ssl"); // open a port to the server if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S) { try { protocol.openSSLPort(); usingSSL = true; } catch (SSLException e) { int result = showErrorDialog(MailResourceLoader.getString( "dialog", "error", "ssl_handshake_error") + ": " + e.getLocalizedMessage() + "\n" + MailResourceLoader.getString("dialog", "error", "ssl_turn_off")); if (result == 1) { throw new CommandCancelledException(); } // turn off SSL for the future item.setBoolean("enable_ssl", false); item.setInteger("port", IMAPProtocol.DEFAULT_PORT); // reopen the port protocol.openPort(); } } else { protocol.openPort(); }
int sslType = popItem.getIntegerWithDefault("ssl_type", IncomingItem.TLS); boolean sslEnabled = popItem.getBoolean("enable_ssl"); // open a port to the server if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S) { try { protocol.openSSLPort(); usingSSL = true; } catch (SSLException e) { int result = showErrorDialog(MailResourceLoader.getString( "dialog", "error", "ssl_handshake_error") + ": " + e.getLocalizedMessage() + "\n" + MailResourceLoader.getString("dialog", "error", "ssl_turn_off")); if (result == JOptionPane.CANCEL_OPTION) { throw new CommandCancelledException(); } // turn off SSL for the future popItem.setBoolean("enable_ssl", false); popItem.setInteger("port", POP3Protocol.DEFAULT_PORT); // reopen the port protocol.openPort(); } } else { protocol.openPort(); }
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 openConnection() Method name: void openConnection()
Number of AST nodes: 7 Number of AST nodes: 7
1
int sslType = item.getIntegerWithDefault("ssl_type", 
1
int sslType = popItem.getIntegerWithDefault("ssl_type",
2
IncomingItem.TLS);
2
				IncomingItem.TLS);
3
		boolean sslEnabled = item.getBoolean("enable_ssl");
3
		boolean sslEnabled = popItem.getBoolean("enable_ssl");
4
		// open a port to the server
4
		// open a port to the server
5
		if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S) {
5
		if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S) {
6
			try {
6
			try {
7
				protocol.openSSLPort();
7
				protocol.openSSLPort();
8
				usingSSL = true;
8
				usingSSL = true;
9
			} catch (SSLException e) {
9
			} catch (SSLException e) {
10
				int result = showErrorDialog(MailResourceLoader.getString(
10
				int result = showErrorDialog(MailResourceLoader.getString(
11
						"dialog", "error", "ssl_handshake_error")
11
						"dialog", "error", "ssl_handshake_error")
12
						+ ": "
12
						+ ": "
13
						+ e.getLocalizedMessage()
13
						+ e.getLocalizedMessage()
14
						+ "\n"
14
						+ "\n"
15
						+ MailResourceLoader.getString("dialog", "error",
15
						+ MailResourceLoader.getString("dialog", "error",
16
								"ssl_turn_off"));
16
								"ssl_turn_off"));
17
				if (result == 1) {
17
				if (result == JOptionPane.CANCEL_OPTION) {
18
					throw new CommandCancelledException();
18
					throw new CommandCancelledException();
19
				}
19
				}
20
				// turn off SSL for the future
20
				// turn off SSL for the future
21
				item.setBoolean("enable_ssl", false);
21
				popItem.setBoolean("enable_ssl", false);
22
				item.setInteger("port", IMAPProtocol.DEFAULT_PORT);
22
				popItem.setInteger("port", POP3Protocol.DEFAULT_PORT);
23
				// reopen the port
23
				// reopen the port
24
				protocol.openPort();
24
				protocol.openPort();
25
			}
25
			}
26
		} else {
26
		} else {
27
			protocol.openPort();
27
			protocol.openPort();
28
		}
28
		}
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 comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    int sslType = item.getIntegerWithDefault("ssl_type", IncomingItem.TLS);
    2
    int sslType = item.getIntegerWithDefault("ssl_type", IncomingItem.TLS);
    1
    int sslType = popItem.getIntegerWithDefault("ssl_type", IncomingItem.TLS);
    Differences
    Expression1Expression2Difference
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    1
    int sslType = popItem.getIntegerWithDefault("ssl_type", IncomingItem.TLS);
    3
    boolean sslEnabled = item.getBoolean("enable_ssl");
    3
    boolean sslEnabled = item.getBoolean("enable_ssl");
    2
    boolean sslEnabled = popItem.getBoolean("enable_ssl");
    Differences
    Expression1Expression2Difference
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    2
    boolean sslEnabled = popItem.getBoolean("enable_ssl");
    4
    if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S)
    3
    if (sslEnabled && sslType == IncomingItem.IMAPS_POP3S)
    5
    try
    5
    try
    4
    try
    Differences
    Expression1Expression2Difference
    1JOptionPane.CANCEL_OPTIONTYPE_COMPATIBLE_REPLACEMENT
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    org.columba.ristretto.imap.IMAPProtocolorg.columba.ristretto.pop3.POP3ProtocolSUBCLASS_TYPE_MISMATCH
    itempopItemVARIABLE_NAME_MISMATCH
    org.columba.mail.config.ImapItemorg.columba.mail.config.PopItemSUBCLASS_TYPE_MISMATCH
    org.columba.ristretto.imap.IMAPProtocolorg.columba.ristretto.pop3.POP3ProtocolSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression IMAPProtocol cannot be unified with expression POP3Protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException, public static final int DEFAULT_PORT
    Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException, public static final int DEFAULT_PORT
    4
    try
    6
    protocol.openSSLPort();
    6
    protocol.openSSLPort();
    5
    protocol.openSSLPort();
    Differences
    Expression1Expression2Difference
    org.columba.ristretto.imap.IMAPProtocolorg.columba.ristretto.pop3.POP3ProtocolSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openSSLPort() throws java.io.IOException, javax.net.ssl.SSLException, org.columba.ristretto.imap.IMAPException
    5
    protocol.openSSLPort();
    7
    usingSSL = true;
    6
    usingSSL = true;
    else
    else
    8
    protocol.openPort();
    8
    protocol.openPort();
    7
    protocol.openPort();
    Differences
    Expression1Expression2Difference
    org.columba.ristretto.imap.IMAPProtocolorg.columba.ristretto.pop3.POP3ProtocolSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException
    7
    protocol.openPort();
    Precondition Violations (5)
    Row Violation
    1Expression IMAPProtocol cannot be unified with expression POP3Protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException, public static final int DEFAULT_PORT
    2Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException, public static final int DEFAULT_PORT
    3Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openSSLPort() throws java.io.IOException, javax.net.ssl.SSLException, org.columba.ristretto.imap.IMAPException
    4Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void openPort() throws java.io.IOException, org.columba.ristretto.imap.IMAPException
    5Clone fragment #1 returns variables sslType, sslEnabled , while Clone fragment #2 returns variables sslType, sslEnabled