<commit_before>package com.example.myfirstapp;

import java.io.IOException;
import java.net.*;

public class UdpBroadcaster implements Runnable {
	public static int PORT = 10332;
    public static String BROADCAST_ADDRESS = "255.255.255.255";

    @Override
    public void run() {
        while (!Thread.interrupted()) {
            try {
                DatagramSocket sendSocket = new DatagramSocket();
                sendSocket.setBroadcast(true);

                byte[] buf = "".getBytes();

                InetAddress ip = InetAddress.getByName(BROADCAST_ADDRESS);

                DatagramPacket sendPacket = new DatagramPacket(buf, buf.length,
                        ip, PORT);

                sendSocket.send(sendPacket);
                sendSocket.close();
                
            } catch (UnknownHostException e) {
				System.out.println("Can't get broadcast address");
				e.printStackTrace();
			} catch (SocketException e) {
				System.out.println("Error opening socket");
				e.printStackTrace();
			} catch (IOException e) {
				System.out.println("Can't send packet");
				e.printStackTrace();
			}
            
            try {    
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                // Ignore
            }
        }
    }

}
  <commit_msg>Updated UdpBroadcaster.java Correctly close UDP Socket after sending broadcast. Correctly break away from while-loop when interrupted during thread sleep.<commit_after>package com.example.myfirstapp;

import java.io.IOException;
import java.net.*;

public class UdpBroadcaster implements Runnable {
	public static int PORT = 10332;
    public static String BROADCAST_ADDRESS = "255.255.255.255";

    @Override
    public void run() {
    	DatagramSocket sendSocket = null;
        while (!Thread.interrupted()) {
            try {
                sendSocket = new DatagramSocket();
                sendSocket.setBroadcast(true);

                byte[] buf = "".getBytes();

                InetAddress ip = InetAddress.getByName(BROADCAST_ADDRESS);

                DatagramPacket sendPacket = new DatagramPacket(buf, buf.length,
                        ip, PORT);

                sendSocket.send(sendPacket);
            } catch (UnknownHostException e) {
				System.out.println("Can't get broadcast address");
				e.printStackTrace();
			} catch (SocketException e) {
				System.out.println("Error opening socket");
				e.printStackTrace();
			} catch (IOException e) {
				System.out.println("Can't send packet");
				e.printStackTrace();
			} finally {
				if(sendSocket != null) {
					sendSocket.close();
					sendSocket = null;
				}
			}
            
            try {    
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                break;
            }
        }
    }

}
  
{'fraction_non_alphanumeric': 0.09761904761904762, 'fraction_numerical': 0.014285714285714285, 'mean_word_length': 1.78240302743614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6638524', 'n_tokens_mistral': 892, 'n_tokens_neox': 735, 'n_words': 177}