tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1633688 - in /tomcat/trunk: java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java webapps/docs/changelog.xml
Date Wed, 22 Oct 2014 19:29:26 GMT
Author: markt
Date: Wed Oct 22 19:29:25 2014
New Revision: 1633688

URL: http://svn.apache.org/r1633688
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57091
Work around the behaviour of the Oracle JRE when creating new threads in an applet environment
that breaks the WebSocket client implementation.
Patch provided by Niklas Hallqvist.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java?rev=1633688&r1=1633687&r2=1633688&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java Wed Oct 22 19:29:25
2014
@@ -18,6 +18,8 @@ package org.apache.tomcat.websocket;
 
 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;
@@ -106,12 +108,21 @@ public class AsyncChannelGroupUtil {
         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;
+                }
+            });
         }
     }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1633688&r1=1633687&r2=1633688&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Oct 22 19:29:25 2014
@@ -233,6 +233,11 @@
         Add null checks for arguments in remote endpoint. (remm/kkolinko)
       </fix>
       <fix>
+        <bug>57091</bug>: Work around the behaviour of the Oracle JRE when
+        creating new threads in an applet environment that breaks the WebSocket
+        client implementation. Patch provided by Niklas Hallqvist. (markt)
+      </fix>
+      <fix>
         <bug>57118</bug>: Ensure that that an <code>EncodeException</code>
is
         thrown by <code>RemoteEndpoint.Basic.sendObject(Object)</code> rather
         than an <code>IOException</code> when no suitable <code>Encoder</code>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message