@Test @Disabled("This test uses a sleep, so could cause issues on slow environments") void onClosedInProgress() throws Exception { PeriodicalChannel pc = createChannelWithNoAvailableData(5, 2); RetrySchema schema = RetrySchema.constant(TimeUnit.SECONDS.toMillis(2)); ReadableByteChannelPublisher publisher = new ReadableByteChannelPublisher(pc, schema); Single<byte[]> data = ContentReaders.readBytes(publisher); data.thenRun(() -> { }); Thread.sleep(1000); pc.close(); CompletionException c = assertThrows(CompletionException.class, () -> data.await(5, TimeUnit.SECONDS)); assertThat(c.getCause(), instanceOf(ClosedChannelException.class)); LazyValue<ScheduledExecutorService> executor = publisher.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; }
ReadableByteChannelPublisher implements Flow.Publisher<DataChunk> { LazyValue<ScheduledExecutorService> executor() { return executor; } }
ReadableByteChannelPublisher implements Flow.Publisher<DataChunk> { LazyValue<ScheduledExecutorService> executor() { return executor; } @Deprecated(since = "2.0.0", forRemoval = true)  ReadableByteChannelPublisher(ReadableByteChannel channel, RetrySchema retrySchema); }
ReadableByteChannelPublisher implements Flow.Publisher<DataChunk> { LazyValue<ScheduledExecutorService> executor() { return executor; } @Deprecated(since = "2.0.0", forRemoval = true)  ReadableByteChannelPublisher(ReadableByteChannel channel, RetrySchema retrySchema); @Override void subscribe(Flow.Subscriber<? super DataChunk> subscriberParam); }
ReadableByteChannelPublisher implements Flow.Publisher<DataChunk> { LazyValue<ScheduledExecutorService> executor() { return executor; } @Deprecated(since = "2.0.0", forRemoval = true)  ReadableByteChannelPublisher(ReadableByteChannel channel, RetrySchema retrySchema); @Override void subscribe(Flow.Subscriber<? super DataChunk> subscriberParam);  }