<commit_before>package hudson;

import hudson.model.Hudson;

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Registers a DNS multi-cast service-discovery support.
 *
 * @author <NAME>
 */
public class DNSMultiCast implements Closeable {
    private JmDNS jmdns;

    public DNSMultiCast(Hudson hudson) {
        try {
            this.jmdns = JmDNS.create();

            Map<String,String> props = new HashMap<String, String>();
            String rootURL = hudson.getRootUrl();
            if (rootURL!=null)
                props.put("url", rootURL);
            try {
                props.put("version",String.valueOf(Hudson.getVersion()));
            } catch (IllegalArgumentException e) {
                // failed to parse the version number
            }

            TcpSlaveAgentListener tal = hudson.getTcpSlaveAgentListener();
            if (tal!=null)
                props.put("slave-port",String.valueOf(tal.getPort()));

            jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","hudson",
                    80,0,0,props));
        } catch (IOException e) {
            LOGGER.log(Level.WARNING,"Failed to advertise the service to DNS multi-cast",e);
        }
    }

    public void close() {
        jmdns.close();
    }

    private static final Logger LOGGER = Logger.getLogger(DNSMultiCast.class.getName());
}<commit_msg>fixed NPE in case of abnormal shutdown<commit_after>package hudson;

import hudson.model.Hudson;

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Registers a DNS multi-cast service-discovery support.
 *
 * @author <NAME>
 */
public class DNSMultiCast implements Closeable {
    private JmDNS jmdns;

    public DNSMultiCast(Hudson hudson) {
        try {
            this.jmdns = JmDNS.create();

            Map<String,String> props = new HashMap<String, String>();
            String rootURL = hudson.getRootUrl();
            if (rootURL!=null)
                props.put("url", rootURL);
            try {
                props.put("version",String.valueOf(Hudson.getVersion()));
            } catch (IllegalArgumentException e) {
                // failed to parse the version number
            }

            TcpSlaveAgentListener tal = hudson.getTcpSlaveAgentListener();
            if (tal!=null)
                props.put("slave-port",String.valueOf(tal.getPort()));

            jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","hudson",
                    80,0,0,props));
        } catch (IOException e) {
            LOGGER.log(Level.WARNING,"Failed to advertise the service to DNS multi-cast",e);
        }
    }

    public void close() {
        if (jmdns!=null) {
            jmdns.close();
            jmdns = null;
        }
    }

    private static final Logger LOGGER = Logger.getLogger(DNSMultiCast.class.getName());
}
{'fraction_non_alphanumeric': 0.11668757841907151, 'fraction_numerical': 0.002509410288582183, 'mean_word_length': 2.342767295597484, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6334494', 'n_tokens_mistral': 976, 'n_tokens_neox': 918, 'n_words': 198}