Search in sources :

Example 1 with AbortPolicy

use of java.util.concurrent.ThreadPoolExecutor.AbortPolicy in project reactor-core by reactor.

the class MonoPublishOnTest method rejectedExecutionSubscribeExecutorServiceScheduler.

@Test
@Ignore
public // FIXME the behavior is not failing fast anymore, find original issue and re-evaluate
void rejectedExecutionSubscribeExecutorServiceScheduler() {
    CountDownLatch latch = new CountDownLatch(1);
    ExecutorService executor = new ThreadPoolExecutor(1, 1, 0L, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
    try {
        executor.submit(() -> {
            try {
                latch.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        try {
            Mono.just(1).publishOn(fromExecutor(executor)).block();
            Assert.fail("Bubbling RejectedExecutionException expected");
        } catch (Exception e) {
            assertThat(Exceptions.unwrap(e), instanceOf(RejectedExecutionException.class));
        }
    } finally {
        latch.countDown();
        executor.shutdownNow();
    }
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) Schedulers.fromExecutorService(reactor.core.scheduler.Schedulers.fromExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CountDownLatch(java.util.concurrent.CountDownLatch) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with AbortPolicy

use of java.util.concurrent.ThreadPoolExecutor.AbortPolicy in project reactor-core by reactor.

the class MonoPublishOnTest method rejectedExecutionSubscribeExecutorScheduler.

@Test
@Ignore
public // FIXME the behavior is not failing fast anymore, find original issue and re-evaluate
void rejectedExecutionSubscribeExecutorScheduler() {
    CountDownLatch latch = new CountDownLatch(1);
    ExecutorService executor = new ThreadPoolExecutor(1, 1, 0L, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
    try {
        executor.submit(() -> {
            try {
                latch.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        try {
            Mono.just(1).publishOn(fromExecutor(executor)).block();
            Assert.fail("Bubbling RejectedExecutionException expected");
        } catch (Exception e) {
            assertThat(Exceptions.unwrap(e), instanceOf(RejectedExecutionException.class));
        }
    } finally {
        latch.countDown();
        executor.shutdownNow();
    }
    executor.shutdownNow();
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) Schedulers.fromExecutorService(reactor.core.scheduler.Schedulers.fromExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CountDownLatch(java.util.concurrent.CountDownLatch) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with AbortPolicy

use of java.util.concurrent.ThreadPoolExecutor.AbortPolicy in project faf-java-server by FAForever.

the class LegacyAdapterConfig method createNioTaskExecutor.

@NotNull
private Executor createNioTaskExecutor(String threadNamePrefix) {
    ThreadPoolTaskExecutor ioExecutor = new ThreadPoolTaskExecutor();
    ioExecutor.setCorePoolSize(1);
    ioExecutor.setMaxPoolSize(4);
    ioExecutor.setQueueCapacity(0);
    ioExecutor.setThreadNamePrefix(threadNamePrefix);
    ioExecutor.setRejectedExecutionHandler(new AbortPolicy());
    ioExecutor.initialize();
    return ioExecutor;
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with AbortPolicy

use of java.util.concurrent.ThreadPoolExecutor.AbortPolicy in project spring-integration by spring-projects.

the class TcpNioConnectionTests method compositeExecutor.

private CompositeExecutor compositeExecutor() {
    ThreadPoolTaskExecutor ioExec = new ThreadPoolTaskExecutor();
    ioExec.setCorePoolSize(2);
    ioExec.setMaxPoolSize(4);
    ioExec.setQueueCapacity(0);
    ioExec.setThreadNamePrefix("io-");
    ioExec.setRejectedExecutionHandler(new AbortPolicy());
    ioExec.initialize();
    ThreadPoolTaskExecutor assemblerExec = new ThreadPoolTaskExecutor();
    assemblerExec.setCorePoolSize(2);
    assemblerExec.setMaxPoolSize(5);
    assemblerExec.setQueueCapacity(0);
    assemblerExec.setThreadNamePrefix("assembler-");
    assemblerExec.setRejectedExecutionHandler(new AbortPolicy());
    assemblerExec.initialize();
    return new CompositeExecutor(ioExec, assemblerExec);
}
Also used : CompositeExecutor(org.springframework.integration.util.CompositeExecutor) AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)

Example 5 with AbortPolicy

use of java.util.concurrent.ThreadPoolExecutor.AbortPolicy in project mule by mulesoft.

the class SimpleUnitTestSupportSchedulerService method customScheduler.

@Override
public Scheduler customScheduler(SchedulerConfig config) {
    final SimpleUnitTestSupportScheduler customScheduler = new SimpleUnitTestSupportCustomScheduler(config.getMaxConcurrentTasks(), buildThreadFactory(config), new AbortPolicy());
    customSchedulers.add(customScheduler);
    final SimpleUnitTestSupportLifecycleSchedulerDecorator decorator = decorateScheduler(customScheduler);
    decorators.add(decorator);
    return decorator;
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy)

Aggregations

AbortPolicy (java.util.concurrent.ThreadPoolExecutor.AbortPolicy)7 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)2 Schedulers.fromExecutorService (reactor.core.scheduler.Schedulers.fromExecutorService)2 AcsJCouldntPerformActionEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)1 AcsJException (alma.acs.exceptions.AcsJException)1 StopWatch (alma.acs.util.StopWatch)1 NcEventSpec (alma.benchmark.NcEventSpec)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 NotNull (org.jetbrains.annotations.NotNull)1 CompositeExecutor (org.springframework.integration.util.CompositeExecutor)1