'ThreadPoolExecutor AbortPolicy not throwing exception

I'm using ThreadPoolExecutor where the default RejectedExecutionHandler is AbortPolicy.

As per the understanding, AbortPolicy will throw a rejection exception once the queue size is full and I'm still pushing the entries to the queue.

This is what I'm using to process something.

CompletableFuture<Void> processTask(Executor executorB) {
        return CompletableFuture.runAsync(
                () -> {
                    // doSomething(...);
                }, executorB);
    }

doSomething(){
 Thread.sleep(1000000l);
System.out.println("doing something");
}

I have another executor (let's say executor A), which is calling the processTask method in a loop 10 times (1 sec delay). For executorB, my queue size is 3, max, and the core pool size is 1. When it is called for the first time it will go in the thread.sleep. As the executorA is continuously sending messages, I should get the rejection exception after 4th message which I'm not seeing anywhere.

Interesting thing is, that the log "doing something" came 4 times which means the tasks after the queue got full were rejected (1 handled by the first call, and 3 were in the queue)

Can someone explain to me why I'm not seeing any exceptions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source