|
20 | 20 | import java.util.concurrent.atomic.AtomicReference; |
21 | 21 | import java.util.stream.Stream; |
22 | 22 |
|
23 | | -import io.netty.channel.Channel; |
24 | | -import io.netty.channel.ChannelInboundHandlerAdapter; |
25 | | -import io.netty.channel.ChannelInitializer; |
26 | | -import io.netty.channel.IoHandle; |
27 | | -import io.netty.channel.IoHandler; |
28 | | -import io.netty.channel.IoHandlerContext; |
29 | | -import io.netty.channel.IoHandlerFactory; |
30 | | -import io.netty.channel.IoRegistration; |
31 | | -import io.netty.channel.epoll.Epoll; |
| 23 | +import io.netty.channel.*; |
32 | 24 | import io.netty.channel.local.LocalIoHandler; |
33 | 25 | import io.netty.channel.epoll.EpollIoHandler; |
34 | 26 | import io.netty.channel.epoll.EpollServerSocketChannel; |
35 | 27 |
|
36 | 28 | import io.netty.channel.uring.IoUring; |
37 | 29 | import io.netty.channel.uring.IoUringIoHandler; |
38 | 30 | import io.netty.channel.uring.IoUringServerSocketChannel; |
| 31 | +import org.junit.jupiter.api.Test; |
39 | 32 | import org.junit.jupiter.params.ParameterizedTest; |
40 | 33 | import org.junit.jupiter.params.provider.MethodSource; |
41 | 34 |
|
@@ -475,7 +468,7 @@ void schedulerIsNotLeakingIfItsThreadFactoryOutliveIt(Transport transport) |
475 | 468 | @ParameterizedTest(name = "{index} => transport={0}") |
476 | 469 | @MethodSource("transportsAllowLocal") |
477 | 470 | void virtualThreadCanMakeProgressEvenIfEventLoopIsClosed(Transport transport) |
478 | | - throws InterruptedException, ExecutionException, TimeoutException, BrokenBarrierException { |
| 471 | + throws InterruptedException, ExecutionException, BrokenBarrierException { |
479 | 472 | var group = new VirtualMultithreadIoEventLoopGroup(1, transport.handlerFactory()); |
480 | 473 | final var barrier = new CyclicBarrier(2); |
481 | 474 | final var vThreadFactory = group.submit(group::vThreadFactory).get(); |
@@ -736,4 +729,23 @@ void testShutdownSchedulerOnLongBlockingIO(Transport transport) |
736 | 729 | } |
737 | 730 | } |
738 | 731 | } |
| 732 | + |
| 733 | + @Test |
| 734 | + void vThreadFactoryMappingShouldReturnNullIfNoneIsFound() throws InterruptedException, ExecutionException { |
| 735 | + try (var otherGroup = new VirtualMultithreadIoEventLoopGroup(1, LocalIoHandler.newFactory()); |
| 736 | + var group = new VirtualMultithreadIoEventLoopGroup(1, NioIoHandler.newFactory())) { |
| 737 | + var otherEventLoop = otherGroup.next(); |
| 738 | + assertNull(group.vThreadFactoryOf(otherEventLoop)); |
| 739 | + } |
| 740 | + } |
| 741 | + |
| 742 | + @Test |
| 743 | + void vThreadFactoryMappingShouldReturnTheRightOne() throws InterruptedException, ExecutionException { |
| 744 | + try (var group = new VirtualMultithreadIoEventLoopGroup(1, NioIoHandler.newFactory())) { |
| 745 | + var eventLoopScheduler = group |
| 746 | + .submit(() -> EventLoopScheduler.currentThreadSchedulerContext().scheduler().get()).get(); |
| 747 | + assertSame(eventLoopScheduler.virtualThreadFactory(), |
| 748 | + group.vThreadFactoryOf(eventLoopScheduler.ioEventLoop())); |
| 749 | + } |
| 750 | + } |
739 | 751 | } |
0 commit comments