<commit_before>package org.jivesoftware.smack;

import java.io.File;

import android.os.Build;

import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.HostAddress;

import java.util.List;

/**
 * This class wraps DNS SRV lookups for a new ConnectionConfiguration in a 
 * new thread, since Android API >= 11 (Honeycomb) does not allow network 
 * activity in the main thread. 
 * 
 * @author <NAME> <EMAIL>
 *
 */
public class AndroidConnectionConfiguration extends ConnectionConfiguration {
    private static final int DEFAULT_TIMEOUT = 10000;

    /**
     * Creates a new ConnectionConfiguration for the specified service name.
     * A DNS SRV lookup will be performed to find out the actual host address
     * and port to use for the connection.
     *
     * @param serviceName the name of the service provided by an XMPP server.
     */
    public AndroidConnectionConfiguration(String serviceName) throws XMPPException {
        super();
        AndroidInit(serviceName, DEFAULT_TIMEOUT);
    }

    /**
     * 
     * @param serviceName
     * @param timeout
     * @throws XMPPException
     */
    public AndroidConnectionConfiguration(String serviceName, int timeout) throws XMPPException {
        super();
        AndroidInit(serviceName, timeout);
    }

    public AndroidConnectionConfiguration(String host, int port, String name) {
        super(host, port, name);
    }

    /**
     * 
     * @param serviceName
     * @param timeout
     * @throws XMPPException
     */
    private void AndroidInit(String serviceName, int timeout) throws XMPPException {
        class DnsSrvLookupRunnable implements Runnable {
            String serviceName;
            List<HostAddress> addresses;

            public DnsSrvLookupRunnable(String serviceName) {
                this.serviceName = serviceName;
            }

            @Override
            public void run() {
                addresses = DNSUtil.resolveXMPPDomain(serviceName);
            }

            public List<HostAddress> getHostAddresses() {
                return addresses;
            }
        }

        DnsSrvLookupRunnable dnsSrv = new DnsSrvLookupRunnable(serviceName);
        Thread t = new Thread(dnsSrv, "dns-srv-lookup");
        t.start();
        try {
            t.join(timeout);
        } catch (InterruptedException e) {
            throw new XMPPException("DNS lookup timeout after " + timeout + "ms", e);
        }

        hostAddresses = dnsSrv.getHostAddresses();
        if (hostAddresses == null) {
            throw new XMPPException("DNS lookup failure");
        }

        ProxyInfo proxy = ProxyInfo.forDefaultProxy();

        init(serviceName, proxy);
    }
}<commit_msg>Adopt new Smack Exceptions API<commit_after>package org.jivesoftware.smack;

import java.io.File;

import android.os.Build;

import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.HostAddress;

import java.util.List;

/**
 * This class wraps DNS SRV lookups for a new ConnectionConfiguration in a 
 * new thread, since Android API >= 11 (Honeycomb) does not allow network 
 * activity in the main thread. 
 * 
 * @author <NAME> <EMAIL>
 *
 */
public class AndroidConnectionConfiguration extends ConnectionConfiguration {
    private static final int DEFAULT_TIMEOUT = 10000;

    /**
     * Creates a new ConnectionConfiguration for the specified service name.
     * A DNS SRV lookup will be performed to find out the actual host address
     * and port to use for the connection.
     *
     * @param serviceName the name of the service provided by an XMPP server.
     */
    public AndroidConnectionConfiguration(String serviceName) throws SmackException {
        super();
        AndroidInit(serviceName, DEFAULT_TIMEOUT);
    }

    /**
     * 
     * @param serviceName
     * @param timeout
     * @throws SmackException
     */
    public AndroidConnectionConfiguration(String serviceName, int timeout) throws SmackException {
        super();
        AndroidInit(serviceName, timeout);
    }

    public AndroidConnectionConfiguration(String host, int port, String name) {
        super(host, port, name);
    }

    /**
     * 
     * @param serviceName
     * @param timeout
     * @throws SmackException
     */
    private void AndroidInit(String serviceName, int timeout) throws SmackException {
        class DnsSrvLookupRunnable implements Runnable {
            String serviceName;
            List<HostAddress> addresses;

            public DnsSrvLookupRunnable(String serviceName) {
                this.serviceName = serviceName;
            }

            @Override
            public void run() {
                addresses = DNSUtil.resolveXMPPDomain(serviceName);
            }

            public List<HostAddress> getHostAddresses() {
                return addresses;
            }
        }

        DnsSrvLookupRunnable dnsSrv = new DnsSrvLookupRunnable(serviceName);
        Thread t = new Thread(dnsSrv, "dns-srv-lookup");
        t.start();
        try {
            t.join(timeout);
        } catch (InterruptedException e) {
            throw new SmackException("DNS lookup timeout after " + timeout + "ms", e);
        }

        hostAddresses = dnsSrv.getHostAddresses();
        if (hostAddresses == null) {
            throw new SmackException("DNS lookup failure");
        }

        ProxyInfo proxy = ProxyInfo.forDefaultProxy();

        init(serviceName, proxy);
    }
}
{'fraction_non_alphanumeric': 0.08135349172066235, 'fraction_numerical': 0.0025197984161267097, 'mean_word_length': 2.4408668730650156, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2018165', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1473, 'n_words': 422}