MyThread.java

1
package com.renomad.minum.utils;
2
3
import com.renomad.minum.logging.Logger;
4
5
/**
6
 * This class exists just to avoid needing to handle
7
 * the exception when I use a regular Thread.sleep()
8
 */
9
public final class MyThread {
10
11
    private MyThread() {
12
        // cannot construct
13
    }
14
15
    /**
16
     * Same behavior as {@link Thread#sleep(long)}, but
17
     * wrapped so that it prints the exception's stacktrace
18
     * instead of letting it bubble up.
19
     * @param millis length of time in milliseconds.
20
     * @return false if the sleep succeeded without being interrupted
21
     */
22
    public static boolean sleep(long millis) {
23
        try {
24
            Thread.sleep(millis);
25
        } catch (InterruptedException e) {
26 1 1. sleep : removed call to com/renomad/minum/utils/MyThread::handleInterrupted → KILLED
            handleInterrupted(e);
27 1 1. sleep : replaced boolean return with true for com/renomad/minum/utils/MyThread::sleep → KILLED
            return false;
28
        }
29 1 1. sleep : replaced boolean return with false for com/renomad/minum/utils/MyThread::sleep → KILLED
        return true;
30
    }
31
32
    static void handleInterrupted(InterruptedException e) {
33
        System.out.println("Interruption during MyThread.sleep: " + Logger.showWhiteSpace(StacktraceUtils.stackTraceToString(e)));
34
        Thread.currentThread().interrupt();
35
    }
36
}

Mutations

26

1.1
Location : sleep
Killed by : com.renomad.minum.utils.MyThreadTests
removed call to com/renomad/minum/utils/MyThread::handleInterrupted → KILLED

27

1.1
Location : sleep
Killed by : com.renomad.minum.utils.MyThreadTests
replaced boolean return with true for com/renomad/minum/utils/MyThread::sleep → KILLED

29

1.1
Location : sleep
Killed by : com.renomad.minum.utils.MyThreadTests
replaced boolean return with false for com/renomad/minum/utils/MyThread::sleep → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0