You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ro...@apache.org on 2007/02/20 23:50:14 UTC
svn commit: r509791 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java
Author: robinsona
Date: Tue Feb 20 14:50:14 2007
New Revision: 509791
URL: http://svn.apache.org/viewvc?view=rev&rev=509791
Log:
do privileged section for java 2 security
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java?view=diff&rev=509791&r1=509790&r2=509791
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/threadpool/ThreadPool.java Tue Feb 20 14:50:14 2007
@@ -21,8 +21,11 @@
import edu.emory.mathcs.backport.java.util.concurrent.SynchronousQueue;
import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import org.apache.axis2.AxisFault;
import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.java.security.AccessController;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -98,11 +101,31 @@
ThreadPoolExecutor rc = new ThreadPoolExecutor(corePoolSize , maxPoolSize , 10,
TimeUnit.SECONDS, new SynchronousQueue(),
new edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory() {
- public Thread newThread(Runnable runnable) {
- Thread thread = new Thread(runnable, name);
- thread.setDaemon(daemon);
- thread.setPriority(priority);
- return thread;
+ public Thread newThread(final Runnable runnable) {
+ // do the following section as privileged
+ // so that it will work even when java2 security
+ // has been enabled
+ Thread returnThread = null;
+ try {
+ returnThread = (Thread) AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public Object run() {
+ Thread newThread = new Thread(runnable, name);
+ newThread.setDaemon(daemon);
+ newThread.setPriority(priority);
+ return newThread;
+ }
+ }
+ );
+ }
+ catch(PrivilegedActionException e) {
+ // note: inner class can't have its own static log variable
+ if (log.isDebugEnabled()) {
+ log.debug("ThreadPoolExecutor.newThread(): Exception from AccessController ["+e.getClass().getName()+"] for ["+e.getMessage()+"]", e);
+ }
+ }
+ return returnThread;
+
}
});
rc.allowCoreThreadTimeOut(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org