MyThread.java

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

Mutations

24

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

25

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

27

1.1
Location : sleep
Killed by : com.renomad.minum.utils.MyThreadTests.testMyThread(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