<commit_before>package net.openhft.chronicle.core.threads;

import net.openhft.chronicle.core.Jvm;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;

import static java.lang.Boolean.*;

/**
 * This will clean up any {@link CleaningThreadLocal}
 */
public class CleaningThread extends Thread {
    private static final Field THREAD_LOCALS;
    private static final Field TABLE;
    private static final Field VALUE;
    private static final boolean DUMP_STACK_ON_INTERRUPT = getBoolean("dumpStack.on.interrupt");

    static {
        THREAD_LOCALS = Jvm.getField(Thread.class, "threadLocals");
        TABLE = Jvm.getField(THREAD_LOCALS.getType(), "table");
        VALUE = Jvm.getField(TABLE.getType().getComponentType(), "value");
    }

    @Override
    public void interrupt() {
        if (DUMP_STACK_ON_INTERRUPT)
            new Exception("*** interrupt ***").printStackTrace();
        super.interrupt();
    }

    public CleaningThread(Runnable target) {
        super(target);
    }

    public CleaningThread(Runnable target, String name) {
        super(target, name);
    }

    public static void performCleanup(Thread thread) {
        WeakReference[] table;
        try {
            Object o = THREAD_LOCALS.get(thread);
            if (o == null)
                return;
            table = (WeakReference[]) TABLE.get(o);
        } catch (IllegalAccessException e) {
            Jvm.debug().on(CleaningThreadLocal.class, e.toString());
            return;
        }
        if (table == null)
            return;

        for (WeakReference reference : table) {
            Object key = reference != null ? reference.get() : null;
            if (!(key instanceof CleaningThreadLocal))
                continue;

            try {
                Object value = VALUE.get(reference);
                if (value == null)
                    continue;

                CleaningThreadLocal ctl = (CleaningThreadLocal) key;
                ctl.cleanup(value);
            } catch (IllegalAccessException e) {
                Jvm.debug().on(CleaningThreadLocal.class, e.toString());
            }
        }
    }

    @Override
    public void run() {
        try {
            super.run();
        } finally {
            performCleanup(this);
        }
    }
}
<commit_msg>reverted last commit<commit_after>package net.openhft.chronicle.core.threads;

import net.openhft.chronicle.core.Jvm;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;

/**
 * This will clean up any {@link CleaningThreadLocal}
 */
public class CleaningThread extends Thread {
    private static final Field THREAD_LOCALS;
    private static final Field TABLE;
    private static final Field VALUE;

    static {
        THREAD_LOCALS = Jvm.getField(Thread.class, "threadLocals");
        TABLE = Jvm.getField(THREAD_LOCALS.getType(), "table");
        VALUE = Jvm.getField(TABLE.getType().getComponentType(), "value");
    }

    public CleaningThread(Runnable target) {
        super(target);
    }

    public CleaningThread(Runnable target, String name) {
        super(target, name);
    }

    public static void performCleanup(Thread thread) {
        WeakReference[] table;
        try {
            Object o = THREAD_LOCALS.get(thread);
            if (o == null)
                return;
            table = (WeakReference[]) TABLE.get(o);
        } catch (IllegalAccessException e) {
            Jvm.debug().on(CleaningThreadLocal.class, e.toString());
            return;
        }
        if (table == null)
            return;

        for (WeakReference reference : table) {
            Object key = reference != null ? reference.get() : null;
            if (!(key instanceof CleaningThreadLocal))
                continue;

            try {
                Object value = VALUE.get(reference);
                if (value == null)
                    continue;

                CleaningThreadLocal ctl = (CleaningThreadLocal) key;
                ctl.cleanup(value);
            } catch (IllegalAccessException e) {
                Jvm.debug().on(CleaningThreadLocal.class, e.toString());
            }
        }
    }

    @Override
    public void run() {
        try {
            super.run();
        } finally {
            performCleanup(this);
        }
    }
}

{'fraction_non_alphanumeric': 0.1057759220598469, 'fraction_numerical': 0.0, 'mean_word_length': 1.984083044982699, 'pattern_counts': {'":': 0, '<': 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': '4045327', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1146, 'n_words': 272}