1
2
3
4
5 package mockit.internal.expectations;
6
7 import edu.umd.cs.findbugs.annotations.NonNull;
8 import edu.umd.cs.findbugs.annotations.Nullable;
9
10 final class FailureState {
11 @NonNull
12 private final Thread testThread;
13 @Nullable
14 private Error errorThrownInAnotherThread;
15
16
17
18
19
20
21
22
23
24 @Nullable
25 private Error errorThrown;
26
27 FailureState() {
28 testThread = Thread.currentThread();
29 }
30
31 @Nullable
32 Error getErrorThrownInAnotherThreadIfAny() {
33 return errorThrownInAnotherThread;
34 }
35
36 @Nullable
37 Error getErrorThrown() {
38 return errorThrown;
39 }
40
41 void setErrorThrown(@Nullable Error error) {
42 errorThrown = error;
43 }
44
45 void clearErrorThrown() {
46 errorThrown = null;
47 }
48
49 void reportErrorThrownIfAny() {
50 if (errorThrown != null) {
51 if (testThread == Thread.currentThread()) {
52 throw errorThrown;
53 }
54
55 errorThrownInAnotherThread = errorThrown;
56 }
57 }
58 }