3. Implement all the new Servlet 3 features
NOTE: Status is based on a review of the specification, not the TCK tests
- - Sections 1 to 15
- - Strict spec compliance requires deployment descriptor validation
+ - Done
4. Do an initial release (from trunk)
- Create tc7.0.x\tags to hold release tags - Done
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
if( context.getLoader() != null ) {
// Not started - it should check for availability first
// This should eventually move to Engine, it's generic.
- Thread.currentThread().setContextClassLoader
- (context.getLoader().getClassLoader());
+ if (Globals.IS_SECURITY_ENABLED) {
+ PrivilegedAction<Void> pa = new PrivilegedSetTccl(
+ context.getLoader().getClassLoader());
+ AccessController.doPrivileged(pa);
+ } else {
+ Thread.currentThread().setContextClassLoader
+ (context.getLoader().getClassLoader());
+ }
}
if (request.isAsyncSupported()) {
request.setAsyncSupported(context.getPipeline().isAsyncSupported());
}
// Restore the context classloader
- Thread.currentThread().setContextClassLoader
- (StandardHostValve.class.getClassLoader());
+ if (Globals.IS_SECURITY_ENABLED) {
+ PrivilegedAction<Void> pa = new PrivilegedSetTccl(
+ StandardHostValve.class.getClassLoader());
+ AccessController.doPrivileged(pa);
+ } else {
+ Thread.currentThread().setContextClassLoader
+ (StandardHostValve.class.getClassLoader());
+ }
}
}
+
+ private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
+ private ClassLoader cl;
+
+ PrivilegedSetTccl(ClassLoader cl) {
+ this.cl = cl;
+ }
+
+ public Void run() {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ }
}
package org.apache.tomcat.util.net;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.RejectedExecutionException;
+import org.apache.catalina.Globals;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.jni.Address;
import org.apache.tomcat.jni.Socket;
import org.apache.tomcat.jni.Status;
+
/**
* APR tailored thread pool, providing the following services:
* <ul>
*/
protected boolean processSocket(long socket, SocketStatus status) {
try {
- getExecutor().execute(new SocketEventProcessor(socket, status));
+ if (status == SocketStatus.OPEN || status == SocketStatus.STOP ||
+ status == SocketStatus.TIMEOUT) {
+ SocketEventProcessor proc =
+ new SocketEventProcessor(socket, status);
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ if (Globals.IS_SECURITY_ENABLED) {
+ PrivilegedAction<Void> pa = new PrivilegedSetTccl(
+ getClass().getClassLoader());
+ AccessController.doPrivileged(pa);
+ } else {
+ Thread.currentThread().setContextClassLoader(
+ getClass().getClassLoader());
+ }
+ getExecutor().execute(proc);
+ } finally {
+ if (Globals.IS_SECURITY_ENABLED) {
+ PrivilegedAction<Void> pa = new PrivilegedSetTccl(loader);
+ AccessController.doPrivileged(pa);
+ } else {
+ Thread.currentThread().setContextClassLoader(loader);
+ }
+ } }
} catch (RejectedExecutionException x) {
log.warn("Socket processing request was rejected for:"+socket,x);
return false;
}
-
+ private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
+
+ private ClassLoader cl;
+
+ PrivilegedSetTccl(ClassLoader cl) {
+ this.cl = cl;
+ }
+
+ public Void run() {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ }
}
protected ConcurrentLinkedQueue<SocketWrapper<Socket>> waitingRequests =
new ConcurrentLinkedQueue<SocketWrapper<Socket>>();
- private static class PrivilegedSetTccl
- implements PrivilegedAction<Void> {
+ private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
private ClassLoader cl;