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