/** * Creates a new {@link WorkQueueProcessor} using the properties * of this builder. * @return a fresh processor */ public WorkQueueProcessor<T> build() { String name = this.name != null ? this.name : WorkQueueProcessor.class.getSimpleName(); WaitStrategy waitStrategy = this.waitStrategy != null ? this.waitStrategy : WaitStrategy.liteBlocking(); ThreadFactory threadFactory = this.executor != null ? null : new EventLoopFactory(name, autoCancel); ExecutorService requestTaskExecutor = this.requestTaskExecutor != null ? this.requestTaskExecutor : defaultRequestTaskExecutor(defaultName(threadFactory, WorkQueueProcessor.class)); return new WorkQueueProcessor<>( threadFactory, executor, requestTaskExecutor, bufferSize, waitStrategy, share, autoCancel); } }
@Test public void customRequestTaskThreadRejectsNull() { ExecutorService customTaskExecutor = null; Assertions.assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> new WorkQueueProcessor<>( Thread::new, Executors.newCachedThreadPool(), customTaskExecutor, 8, WaitStrategy.liteBlocking(), true, true) ); }
/** * Creates a new {@link WorkQueueProcessor} using the properties * of this builder. * @return a fresh processor */ public WorkQueueProcessor<T> build() { String name = this.name != null ? this.name : WorkQueueProcessor.class.getSimpleName(); WaitStrategy waitStrategy = this.waitStrategy != null ? this.waitStrategy : WaitStrategy.liteBlocking(); ThreadFactory threadFactory = this.executor != null ? null : new EventLoopFactory(name, autoCancel); ExecutorService requestTaskExecutor = this.requestTaskExecutor != null ? this.requestTaskExecutor : defaultRequestTaskExecutor(defaultName(threadFactory, WorkQueueProcessor.class)); return new WorkQueueProcessor<>( threadFactory, executor, requestTaskExecutor, bufferSize, waitStrategy, share, autoCancel); } }