Merge remote-tracking branch 'origin/jetty-9.2.x'

Conflicts:
	jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
	jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
This commit is contained in:
Greg Wilkins 2015-01-07 23:42:10 +01:00
commit 629035ba7a
8 changed files with 29 additions and 27 deletions

View File

@ -126,14 +126,14 @@ public class ServletCallbackHandler implements CallbackHandler
public CallerPrincipalCallback getThreadCallerPrincipalCallback()
{
CallerPrincipalCallback callerPrincipalCallback = _callerPrincipals.get();
_callerPrincipals.remove();
_callerPrincipals.set(null);
return callerPrincipalCallback;
}
public GroupPrincipalCallback getThreadGroupPrincipalCallback()
{
GroupPrincipalCallback groupPrincipalCallback = _groupPrincipals.get();
_groupPrincipals.remove();
_groupPrincipals.set(null);
return groupPrincipalCallback;
}
}

View File

@ -211,7 +211,6 @@ public class ContextFactory implements ObjectFactory
return (Context)__contextMap.get(loader);
}
/**
* Associate the given Context with the current thread.
* disassociate method should be called to reset the context.
@ -227,10 +226,9 @@ public class ContextFactory implements ObjectFactory
public static void disassociateContext(final Context ctx)
{
__threadContext.remove();
__threadContext.set(null);
}
public static ClassLoader associateClassLoader(final ClassLoader loader)
{
ClassLoader prev = (ClassLoader)__threadClassLoader.get();
@ -238,10 +236,9 @@ public class ContextFactory implements ObjectFactory
return prev;
}
public static void disassociateClassLoader ()
{
__threadClassLoader.remove();
__threadClassLoader.set(null);
}
public static void dump(Appendable out, String indent) throws IOException
@ -259,5 +256,4 @@ public class ContextFactory implements ObjectFactory
context.dump(out,indent+(last?" ":" | "));
}
}
}

View File

@ -28,6 +28,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -44,6 +45,7 @@ import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConnection;
import org.eclipse.jetty.server.HttpTransport;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.util.BufferUtil;
@ -210,14 +212,14 @@ public class ConnectHandler extends HandlerWrapper
* <p>CONNECT requests may have authentication headers such as {@code Proxy-Authorization}
* that authenticate the client with the proxy.</p>
*
* @param jettyRequest Jetty-specific http request
* @param baseRequest Jetty-specific http request
* @param request the http request
* @param response the http response
* @param serverAddress the remote server address in the form {@code host:port}
*/
protected void handleConnect(Request jettyRequest, HttpServletRequest request, HttpServletResponse response, String serverAddress)
protected void handleConnect(Request baseRequest, HttpServletRequest request, HttpServletResponse response, String serverAddress)
{
jettyRequest.setHandled(true);
baseRequest.setHandled(true);
try
{
boolean proceed = handleAuthentication(request, response, serverAddress);
@ -256,8 +258,18 @@ public class ConnectHandler extends HandlerWrapper
if (LOG.isDebugEnabled())
LOG.debug("Connecting to {}", address);
ConnectContext connectContext = new ConnectContext(request, response, asyncContext, HttpConnection.getCurrentConnection());
HttpTransport transport = baseRequest.getHttpChannel().getHttpTransport();
if (!(transport instanceof HttpConnection))
{
if (LOG.isDebugEnabled())
LOG.debug("CONNECT forbidden for {}", transport);
sendConnectResponse(request, response, HttpServletResponse.SC_FORBIDDEN);
return;
}
ConnectContext connectContext = new ConnectContext(request, response, asyncContext, (HttpConnection)transport);
if (channel.connect(address))
selector.accept(channel, connectContext);
else

View File

@ -347,9 +347,9 @@ public class ProxyTunnellingTest
startProxy(new ConnectHandler()
{
@Override
protected void handleConnect(Request jettyRequest, HttpServletRequest request, HttpServletResponse response, String serverAddress)
protected void handleConnect(Request baseRequest, HttpServletRequest request, HttpServletResponse response, String serverAddress)
{
HttpConnection.getCurrentConnection().close();
((HttpConnection)baseRequest.getHttpChannel().getHttpTransport()).close();
}
});

View File

@ -80,10 +80,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
protected static HttpChannel setCurrentHttpChannel(HttpChannel channel)
{
HttpChannel last=__currentChannel.get();
if (channel==null)
__currentChannel.remove();
else
__currentChannel.set(channel);
__currentChannel.set(channel);
return last;
}

View File

@ -75,10 +75,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
protected static HttpConnection setCurrentConnection(HttpConnection connection)
{
HttpConnection last=__currentConnection.get();
if (connection==null)
__currentConnection.remove();
else
__currentConnection.set(connection);
__currentConnection.set(connection);
return last;
}

View File

@ -42,14 +42,14 @@ public class SecuredRedirectHandler extends AbstractHandler
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
HttpConnection connection = HttpConnection.getCurrentConnection();
if (baseRequest.isSecure() || (connection == null))
HttpChannel channel = baseRequest.getHttpChannel();
if (baseRequest.isSecure() || (channel == null))
{
// nothing to do
return;
}
HttpConfiguration httpConfig = connection.getHttpConfiguration();
HttpConfiguration httpConfig = channel.getHttpConfiguration();
if (httpConfig == null)
{
// no config, show error

View File

@ -53,7 +53,7 @@ public class NonBlockingThread implements Runnable
}
finally
{
__nonBlockingThread.remove();
__nonBlockingThread.set(Boolean.FALSE);
}
}
}