Author: remy.maucherat(a)jboss.com
Date: 2014-10-23 08:06:30 -0400 (Thu, 23 Oct 2014)
New Revision: 2533
Modified:
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java
Log:
Port websocket patch: use a PA to create client threads.
Modified:
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java
===================================================================
---
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java 2014-10-22
16:05:37 UTC (rev 2532)
+++
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java 2014-10-23
12:06:30 UTC (rev 2533)
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.nio.channels.AsynchronousChannelGroup;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
@@ -104,12 +106,21 @@
private AtomicInteger count = new AtomicInteger(0);
@Override
- public Thread newThread(Runnable r) {
- Thread t = new Thread(r);
- t.setName("WebSocketClient-AsyncIO-" + count.incrementAndGet());
- t.setContextClassLoader(this.getClass().getClassLoader());
- t.setDaemon(true);
- return t;
+ public Thread newThread(final Runnable r) {
+ // Create the new Thread within a doPrivileged block to ensure that
+ // the thread inherits the current ProtectionDomain which is
+ // essential to be able to use this with a Java Applet. See
+ //
https://issues.apache.org/bugzilla/show_bug.cgi?id=57091
+ return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
+ @Override
+ public Thread run() {
+ Thread t = new Thread(r);
+ t.setName("WebSocketClient-AsyncIO-" +
count.incrementAndGet());
+ t.setContextClassLoader(this.getClass().getClassLoader());
+ t.setDaemon(true);
+ return t;
+ }
+ });
}
}
}