File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
junit-platform-engine/src/main/java/org/junit/platform/engine/support/store
platform-tests/src/test/java/org/junit/platform/engine/support/store Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ private void close(CloseAction<N> closeAction) throws Throwable {
565565 * {@link ConcurrentHashMap#compute(Object, BiFunction)} calls and
566566 * prevents recursive updates.
567567 */
568- private static final class DeferredSupplier implements Supplier <@ Nullable Object > {
568+ static final class DeferredSupplier implements Supplier <@ Nullable Object > {
569569
570570 private final FutureTask <@ Nullable Object > task ;
571571 private final @ Nullable Object ownerToken ;
Original file line number Diff line number Diff line change 1616import static org .junit .jupiter .api .Assertions .assertNull ;
1717import static org .junit .jupiter .api .Assertions .assertSame ;
1818import static org .junit .jupiter .api .Assertions .assertThrows ;
19+ import static org .junit .jupiter .api .Assertions .assertTrue ;
1920import static org .junit .platform .commons .test .ConcurrencyTestingUtils .executeConcurrently ;
2021import static org .mockito .Mockito .doThrow ;
2122import static org .mockito .Mockito .inOrder ;
@@ -732,6 +733,28 @@ private void assertClosed() {
732733
733734 }
734735
736+ @ Nested
737+ class DeferredSupplierTests {
738+
739+ @ Test
740+ void getCanBeInterrupted () {
741+ var supplier = new NamespacedHierarchicalStore .DeferredSupplier (() -> {
742+ try {
743+ Thread .sleep (1000 );
744+ }
745+ catch (InterruptedException e ) {
746+ throw new ComputeException (e );
747+ }
748+ return value ;
749+ });
750+ Thread .currentThread ().interrupt ();
751+ assertThrows (InterruptedException .class , () -> {
752+ supplier .get ();
753+ });
754+ assertTrue (Thread .interrupted ());
755+ }
756+ }
757+
735758 private static Object createObject (String display ) {
736759 return new Object () {
737760
@@ -753,5 +776,9 @@ private static final class ComputeException extends RuntimeException {
753776 ComputeException (String msg ) {
754777 super (msg );
755778 }
779+
780+ ComputeException (InterruptedException e ) {
781+ super (e );
782+ }
756783 }
757784}
You can’t perform that action at this time.
0 commit comments