Handle starvation in apache commons-pool

Viewed 435

I am using 1.6 version of apache commons-pool library. As per the javadoc,

whenExhaustedAction specifies the behavior of the borrowObject() method when the pool is exhausted: It can be either WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW, or WHEN_EXHAUSTED_BLOCK.

I want to use the borrowObject and if don't get the object within a specified timeframe, I need some sort of handle to handle the scenario(like i will be rescheduling the tasks, if i don't get the target object)

But the only option, I get here is NoSuchElementException which is a RuntimeException, which I need to catch and handle the error scenario. I am quite sceptical about catching the RuntimeException

Is this the intended way of handling object starvation with GenericObjectPool or do I have any other options ?

1 Answers
Related