Hi

This is rather ugly to silently change 0 to 1 without end user noticing.
Instead lets thrown an IllegalArgumentException and require core pool
size to be 1 or higher.

Then in Camel 3 we can allow a core size of 0. Which the thread pool
in JDK 1.6 seems to accept better than 1.5.


On Wed, Oct 13, 2010 at 9:53 AM,  <[email protected]> wrote:
> Author: ningjiang
> Date: Wed Oct 13 07:53:09 2010
> New Revision: 1022017
>
> URL: http://svn.apache.org/viewvc?rev=1022017&view=rev
> Log:
> CAMEL-3220 try to fix the test hang of ThreadsZeroInCoreAndMaxPoolTest
>
> Modified:
>    
> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
>
> Modified: 
> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
> URL: 
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java?rev=1022017&r1=1022016&r2=1022017&view=diff
> ==============================================================================
> --- 
> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
>  (original)
> +++ 
> camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
>  Wed Oct 13 07:53:09 2010
> @@ -269,7 +269,13 @@ public class DefaultExecutorServiceStrat
>
>         // the thread name must not be null
>         ObjectHelper.notNull(name, "ThreadName");
> -
> +
> +        // If we set the corePoolSize to be 0, the whole camel application 
> will hang in JDK5
> +        // just add a check here to set the corePoolSize to be 1
> +        if (corePoolSize == 0) {
> +            corePoolSize = 1;
> +        }
> +
>         ExecutorService answer = 
> ExecutorServiceHelper.newThreadPool(threadNamePattern, name, corePoolSize, 
> maxPoolSize, keepAliveTime,
>                                                                      
> timeUnit, maxQueueSize, rejectedExecutionHandler, daemon);
>         onThreadPoolCreated(answer);
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to