You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2010/10/13 21:11:45 UTC
svn commit: r1022245 -
/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java
Author: lhein
Date: Wed Oct 13 19:11:44 2010
New Revision: 1022245
URL: http://svn.apache.org/viewvc?rev=1022245&view=rev
Log:
using now reflection to detect if Java version supports method allowsCoreThreadTImeout of ThreadPoolExecutor (see SM-2001 and SMX4-606)
Modified:
servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java
Modified: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java?rev=1022245&r1=1022244&r2=1022245&view=diff
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java (original)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ManagedExecutor.java Wed Oct 13 19:11:44 2010
@@ -18,6 +18,8 @@
*/
package org.apache.servicemix.executors.impl;
+import java.lang.reflect.Method;
+import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
@@ -101,9 +103,20 @@ public class ManagedExecutor extends jav
}
public boolean isAllowCoreThreadTimeout() {
+ if (this.internalExecutor != null) {
+ ThreadPoolExecutor executor = this.internalExecutor.getThreadPoolExecutor();
+ try {
+ Method m = ThreadPoolExecutor.class.getMethod("allowsCoreThreadTimeOut", null);
+ try {
+ return (Boolean) m.invoke(executor, null);
+ } catch (Exception ex) {
+ // ignore
+ }
+ } catch (NoSuchMethodException ex) {
+ // ignore
+ }
+ }
return false;
- // TODO: put me back in after switchover to Java 6
- // return this.internalExecutor != null && this.internalExecutor.getThreadPoolExecutor().allowsCoreThreadTimeOut();
}
public long getNumberOfRejectedExecutions() {