@Test @Disabled("This test uses a sleep, so could cause issues on slow environments") void testOnClosedInProgress() throws Exception { PeriodicalChannel pc = createChannelWithNoAvailableData(5, 2); Multi<ByteBuffer> publisher = IoMulti.multiFromByteChannelBuilder(pc) .retrySchema(RetrySchema.constant(TimeUnit.SECONDS.toMillis(2))) .build(); Single<byte[]> data = Multi.create(publisher) .collect(new BufferCollector()); data.thenRun(() -> { }); Thread.sleep(1000); pc.close(); CompletionException c = assertThrows(CompletionException.class, () -> data.await(5, TimeUnit.SECONDS)); assertThat(c.getCause(), instanceOf(ClosedChannelException.class)); MultiFromByteChannel multi = (MultiFromByteChannel) publisher; LazyValue<ScheduledExecutorService> executor = multi.executor(); assertThat("Executor should have been used", executor.isLoaded(), is(true)); assertThat("Executor should have been shut down", executor.get().isShutdown(), is(true)); }
LazyValue<ScheduledExecutorService> executor() { return executor; }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); @Override void subscribe(Flow.Subscriber<? super ByteBuffer> subscriberParam); }
MultiFromByteChannel implements Multi<ByteBuffer> { LazyValue<ScheduledExecutorService> executor() { return executor; } MultiFromByteChannel(IoMulti.MultiFromByteChannelBuilder builder); @Override void subscribe(Flow.Subscriber<? super ByteBuffer> subscriberParam);  }