File tree 4 files changed +22
-10
lines changed
guava/src/com/google/common/util/concurrent
guava-tests/test/com/google/common/util/concurrent
guava/src/com/google/common/util/concurrent
guava-tests/test/com/google/common/util/concurrent
4 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 20
20
import static org .mockito .Mockito .verify ;
21
21
22
22
import com .google .common .util .concurrent .UncaughtExceptionHandlers .Exiter ;
23
+ import com .google .common .util .concurrent .UncaughtExceptionHandlers .RuntimeWrapper ;
23
24
import junit .framework .TestCase ;
24
25
import org .jspecify .annotations .NullUnmarked ;
25
26
29
30
@ NullUnmarked
30
31
public class UncaughtExceptionHandlersTest extends TestCase {
31
32
32
- private Runtime runtimeMock ;
33
+ private RuntimeWrapper runtimeMock ;
33
34
34
35
@ Override
35
36
protected void setUp () {
36
- runtimeMock = mock (Runtime .class );
37
+ runtimeMock = mock (RuntimeWrapper .class );
37
38
}
38
39
39
40
public void testExiter () {
Original file line number Diff line number Diff line change @@ -50,16 +50,21 @@ private UncaughtExceptionHandlers() {}
50
50
* process with an exit status of 1, indicating abnormal termination.
51
51
*/
52
52
public static UncaughtExceptionHandler systemExit () {
53
- return new Exiter (Runtime .getRuntime ());
53
+ return new Exiter (Runtime .getRuntime ()::exit );
54
+ }
55
+
56
+ @ VisibleForTesting
57
+ interface RuntimeWrapper {
58
+ void exit (int status );
54
59
}
55
60
56
61
@ VisibleForTesting
57
62
static final class Exiter implements UncaughtExceptionHandler {
58
63
private static final LazyLogger logger = new LazyLogger (Exiter .class );
59
64
60
- private final Runtime runtime ;
65
+ private final RuntimeWrapper runtime ;
61
66
62
- Exiter (Runtime runtime ) {
67
+ Exiter (RuntimeWrapper runtime ) {
63
68
this .runtime = runtime ;
64
69
}
65
70
Original file line number Diff line number Diff line change 20
20
import static org .mockito .Mockito .verify ;
21
21
22
22
import com .google .common .util .concurrent .UncaughtExceptionHandlers .Exiter ;
23
+ import com .google .common .util .concurrent .UncaughtExceptionHandlers .RuntimeWrapper ;
23
24
import junit .framework .TestCase ;
24
25
import org .jspecify .annotations .NullUnmarked ;
25
26
29
30
@ NullUnmarked
30
31
public class UncaughtExceptionHandlersTest extends TestCase {
31
32
32
- private Runtime runtimeMock ;
33
+ private RuntimeWrapper runtimeMock ;
33
34
34
35
@ Override
35
36
protected void setUp () {
36
- runtimeMock = mock (Runtime .class );
37
+ runtimeMock = mock (RuntimeWrapper .class );
37
38
}
38
39
39
40
public void testExiter () {
Original file line number Diff line number Diff line change @@ -50,16 +50,21 @@ private UncaughtExceptionHandlers() {}
50
50
* process with an exit status of 1, indicating abnormal termination.
51
51
*/
52
52
public static UncaughtExceptionHandler systemExit () {
53
- return new Exiter (Runtime .getRuntime ());
53
+ return new Exiter (Runtime .getRuntime ()::exit );
54
+ }
55
+
56
+ @ VisibleForTesting
57
+ interface RuntimeWrapper {
58
+ void exit (int status );
54
59
}
55
60
56
61
@ VisibleForTesting
57
62
static final class Exiter implements UncaughtExceptionHandler {
58
63
private static final LazyLogger logger = new LazyLogger (Exiter .class );
59
64
60
- private final Runtime runtime ;
65
+ private final RuntimeWrapper runtime ;
61
66
62
- Exiter (Runtime runtime ) {
67
+ Exiter (RuntimeWrapper runtime ) {
63
68
this .runtime = runtime ;
64
69
}
65
70
You can’t perform that action at this time.
0 commit comments