<commit_before>package net.sf.jaer.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/** A thread group that implements uncaughtException to log uncaught exceptions */
public class LoggingThreadGroup extends ThreadGroup {
    private static Logger logger;
    public LoggingThreadGroup(String name) {
        super(name);
    }

    /** Thread and Throwable passed in here are passed to a
     * Logger named "UncaughtExceptionLogger"
     * which has the handler LoggingWindowHandler.
     */
    public void uncaughtException(Thread t, Throwable e) {
        // Initialize logger once
        if (logger == null) {
            logger = Logger.getLogger("UncaughtExceptionLogger");
            Handler handler = LoggingWindowHandler.getInstance();
            logger.addHandler(handler);
        }
        logger.log(Level.WARNING, t.getName(), e);
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        pw.flush();
        String st=sw.toString();
        logger.log(Level.WARNING,st);
    }
//    public static void main(String args[]) throws Exception {
//        Thread.UncaughtExceptionHandler handler = new LoggingThreadGroup("Logger");
//        Thread.currentThread().setUncaughtExceptionHandler(handler);
//        System.out.println(1 / 0);
//    }
}

<commit_msg>checking now for null exception or cause in exception handler<commit_after>package net.sf.jaer.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/** A thread group that implements uncaughtException to log uncaught exceptions */
public class LoggingThreadGroup extends ThreadGroup {
    private static Logger logger;
    public LoggingThreadGroup(String name) {
        super(name);
    }

    /** Thread and Throwable passed in here are passed to a
     * Logger named "UncaughtExceptionLogger"
     * which has the handler LoggingWindowHandler.
     */
    public void uncaughtException(Thread t, Throwable e) {
        // Initialize logger once
        if (logger == null) {
            logger = Logger.getLogger("UncaughtExceptionLogger");
            Handler handler = LoggingWindowHandler.getInstance();
            logger.addHandler(handler);
        }
        logger.log(Level.WARNING, t==null?"(null thread supplied)":t.getName(), e==null?"(null exception)":e.toString());
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        if(e!=null){
            e.printStackTrace(pw);
        }else{
            sw.write("(null exception, cannot provide stack trace)");
        }
        pw.flush();
        String st=sw.toString();
        logger.log(Level.WARNING,st);
    }
//    public static void main(String args[]) throws Exception {
//        Thread.UncaughtExceptionHandler handler = new LoggingThreadGroup("Logger");
//        Thread.currentThread().setUncaughtExceptionHandler(handler);
//        System.out.println(1 / 0);
//    }
}


{'fraction_non_alphanumeric': 0.10458320516764072, 'fraction_numerical': 0.0012303906490310674, 'mean_word_length': 2.6375838926174495, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '5207366', 'n_tokens_mistral': 846, 'n_tokens_neox': 849, 'n_words': 223}