You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2010/10/13 13:58:32 UTC
Re: svn commit: r1022017 - /camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
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, <ni...@apache.org> 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
Re: svn commit: r1022017 - /camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
Posted by Willem Jiang <wi...@gmail.com>.
OK, I will change the code to throw the IllegalArguementException for
this case.
On 10/13/10 7:58 PM, Claus Ibsen wrote:
> 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,<ni...@apache.org> 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);
>>
>>
>>
>
>
>
--
Willem
----------------------------------
Open Source Integration: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang