Merge remote-tracking branch 'origin/master' into jetty-http2
Conflicts: jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java
This commit is contained in:
commit
fa3d7d0f7e
|
@ -441,14 +441,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
// Resolve container initializers
|
// Resolve container initializers
|
||||||
List<ContainerInitializer> initializers =
|
List<ContainerInitializer> initializers =
|
||||||
(List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
(List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||||
if (initializers != null && initializers.size()>0)
|
if (initializers != null && initializers.size()>0)
|
||||||
{
|
{
|
||||||
Map<String, Set<String>> map = ( Map<String, Set<String>>) context.getAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP);
|
Map<String, Set<String>> map = ( Map<String, Set<String>>) context.getAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP);
|
||||||
if (map == null)
|
if (map == null)
|
||||||
LOG.warn ("ServletContainerInitializers: detected. Class hierarchy: empty");
|
LOG.warn ("ServletContainerInitializers: detected. Class hierarchy: empty");
|
||||||
for (ContainerInitializer i : initializers)
|
for (ContainerInitializer i : initializers)
|
||||||
i.resolveClasses(context,map);
|
i.resolveClasses(context,map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1049,9 +1049,9 @@ public class SslBytesServerTest extends SslBytesTest
|
||||||
@Test
|
@Test
|
||||||
public void testRequestWithBigContentWriteBlockedThenReset() throws Exception
|
public void testRequestWithBigContentWriteBlockedThenReset() throws Exception
|
||||||
{
|
{
|
||||||
// Don't run on Windows (buggy JVM)
|
// Don't run on Windows (buggy JVM)
|
||||||
Assume.assumeTrue(!OS.IS_WINDOWS);
|
Assume.assumeTrue(!OS.IS_WINDOWS);
|
||||||
|
|
||||||
final SSLSocket client = newClient();
|
final SSLSocket client = newClient();
|
||||||
|
|
||||||
SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow();
|
SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow();
|
||||||
|
@ -1110,10 +1110,10 @@ public class SslBytesServerTest extends SslBytesTest
|
||||||
@Test
|
@Test
|
||||||
public void testRequestWithBigContentReadBlockedThenReset() throws Exception
|
public void testRequestWithBigContentReadBlockedThenReset() throws Exception
|
||||||
{
|
{
|
||||||
// Don't run on Windows (buggy JVM)
|
// Don't run on Windows (buggy JVM)
|
||||||
Assume.assumeTrue(!OS.IS_WINDOWS);
|
Assume.assumeTrue(!OS.IS_WINDOWS);
|
||||||
|
|
||||||
final SSLSocket client = newClient();
|
final SSLSocket client = newClient();
|
||||||
|
|
||||||
SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow();
|
SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow();
|
||||||
client.startHandshake();
|
client.startHandshake();
|
||||||
|
|
|
@ -36,10 +36,10 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class AppLifeCycleTest
|
public class AppLifeCycleTest
|
||||||
{
|
{
|
||||||
@Rule
|
@Rule
|
||||||
public TestingDir testdir = new TestingDir();
|
public TestingDir testdir = new TestingDir();
|
||||||
|
|
||||||
private void assertNoPath(String from, String to)
|
private void assertNoPath(String from, String to)
|
||||||
{
|
{
|
||||||
assertPath(from,to,new ArrayList<String>());
|
assertPath(from,to,new ArrayList<String>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class ScanningAppProviderStartupTest
|
public class ScanningAppProviderStartupTest
|
||||||
{
|
{
|
||||||
@Rule
|
@Rule
|
||||||
public TestingDir testdir = new TestingDir();
|
public TestingDir testdir = new TestingDir();
|
||||||
private static XmlConfiguredJetty jetty;
|
private static XmlConfiguredJetty jetty;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -97,8 +97,8 @@ public class JettyHttpContext extends com.sun.net.httpserver.HttpContext
|
||||||
@Override
|
@Override
|
||||||
public Authenticator setAuthenticator(Authenticator auth)
|
public Authenticator setAuthenticator(Authenticator auth)
|
||||||
{
|
{
|
||||||
Authenticator previous = _authenticator;
|
Authenticator previous = _authenticator;
|
||||||
_authenticator = auth;
|
_authenticator = auth;
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,271 +1,271 @@
|
||||||
//
|
//
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// All rights reserved. This program and the accompanying materials
|
// All rights reserved. This program and the accompanying materials
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
//
|
//
|
||||||
// The Eclipse Public License is available at
|
// The Eclipse Public License is available at
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
//
|
//
|
||||||
// The Apache License v2.0 is available at
|
// The Apache License v2.0 is available at
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
//
|
//
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
package org.eclipse.jetty.http.spi;
|
package org.eclipse.jetty.http.spi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Connector;
|
import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.NetworkConnector;
|
import org.eclipse.jetty.server.NetworkConnector;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpContext;
|
import com.sun.net.httpserver.HttpContext;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jetty implementation of {@link com.sun.net.httpserver.HttpServer}.
|
* Jetty implementation of {@link com.sun.net.httpserver.HttpServer}.
|
||||||
*/
|
*/
|
||||||
public class JettyHttpServer extends com.sun.net.httpserver.HttpServer
|
public class JettyHttpServer extends com.sun.net.httpserver.HttpServer
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(JettyHttpServer.class);
|
private static final Logger LOG = Log.getLogger(JettyHttpServer.class);
|
||||||
|
|
||||||
|
|
||||||
private Server _server;
|
private Server _server;
|
||||||
|
|
||||||
private boolean _serverShared;
|
private boolean _serverShared;
|
||||||
|
|
||||||
private InetSocketAddress _addr;
|
private InetSocketAddress _addr;
|
||||||
|
|
||||||
private ThreadPoolExecutor _executor;
|
private ThreadPoolExecutor _executor;
|
||||||
|
|
||||||
private Map<String, JettyHttpContext> _contexts = new HashMap<String, JettyHttpContext>();
|
private Map<String, JettyHttpContext> _contexts = new HashMap<String, JettyHttpContext>();
|
||||||
|
|
||||||
private Map<String, Connector> _connectors = new HashMap<String, Connector>();
|
private Map<String, Connector> _connectors = new HashMap<String, Connector>();
|
||||||
|
|
||||||
|
|
||||||
public JettyHttpServer(Server server, boolean shared)
|
public JettyHttpServer(Server server, boolean shared)
|
||||||
{
|
{
|
||||||
this._server = server;
|
this._server = server;
|
||||||
this._serverShared = shared;
|
this._serverShared = shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bind(InetSocketAddress addr, int backlog) throws IOException
|
public void bind(InetSocketAddress addr, int backlog) throws IOException
|
||||||
{
|
{
|
||||||
// check if there is already a connector listening
|
// check if there is already a connector listening
|
||||||
Collection<NetworkConnector> connectors = _server.getBeans(NetworkConnector.class);
|
Collection<NetworkConnector> connectors = _server.getBeans(NetworkConnector.class);
|
||||||
if (connectors != null)
|
if (connectors != null)
|
||||||
{
|
{
|
||||||
for (NetworkConnector connector : connectors)
|
for (NetworkConnector connector : connectors)
|
||||||
{
|
{
|
||||||
if (connector.getPort() == addr.getPort()) {
|
if (connector.getPort() == addr.getPort()) {
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("server already bound to port " + addr.getPort() + ", no need to rebind");
|
if (LOG.isDebugEnabled()) LOG.debug("server already bound to port " + addr.getPort() + ", no need to rebind");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_serverShared)
|
if (_serverShared)
|
||||||
throw new IOException("jetty server is not bound to port " + addr.getPort());
|
throw new IOException("jetty server is not bound to port " + addr.getPort());
|
||||||
|
|
||||||
this._addr = addr;
|
this._addr = addr;
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("binding server to port " + addr.getPort());
|
if (LOG.isDebugEnabled()) LOG.debug("binding server to port " + addr.getPort());
|
||||||
ServerConnector connector = new ServerConnector(_server);
|
ServerConnector connector = new ServerConnector(_server);
|
||||||
connector.setPort(addr.getPort());
|
connector.setPort(addr.getPort());
|
||||||
connector.setHost(addr.getHostName());
|
connector.setHost(addr.getHostName());
|
||||||
_server.addConnector(connector);
|
_server.addConnector(connector);
|
||||||
|
|
||||||
_connectors.put(addr.getHostName() + addr.getPort(), connector);
|
_connectors.put(addr.getHostName() + addr.getPort(), connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetSocketAddress getAddress()
|
public InetSocketAddress getAddress()
|
||||||
{
|
{
|
||||||
return _addr;
|
return _addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
if (_serverShared) return;
|
if (_serverShared) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_server.start();
|
_server.start();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setExecutor(Executor executor)
|
public void setExecutor(Executor executor)
|
||||||
{
|
{
|
||||||
if (executor == null)
|
if (executor == null)
|
||||||
throw new IllegalArgumentException("missing required 'executor' argument");
|
throw new IllegalArgumentException("missing required 'executor' argument");
|
||||||
ThreadPool threadPool = _server.getThreadPool();
|
ThreadPool threadPool = _server.getThreadPool();
|
||||||
if (threadPool instanceof DelegatingThreadPool)
|
if (threadPool instanceof DelegatingThreadPool)
|
||||||
((DelegatingThreadPool)_server.getThreadPool()).setExecutor(executor);
|
((DelegatingThreadPool)_server.getThreadPool()).setExecutor(executor);
|
||||||
else
|
else
|
||||||
throw new UnsupportedOperationException("!DelegatingThreadPool");
|
throw new UnsupportedOperationException("!DelegatingThreadPool");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor getExecutor()
|
public Executor getExecutor()
|
||||||
{
|
{
|
||||||
ThreadPool threadPool = _server.getThreadPool();
|
ThreadPool threadPool = _server.getThreadPool();
|
||||||
if (threadPool instanceof DelegatingThreadPool)
|
if (threadPool instanceof DelegatingThreadPool)
|
||||||
return ((DelegatingThreadPool)_server.getThreadPool()).getExecutor();
|
return ((DelegatingThreadPool)_server.getThreadPool()).getExecutor();
|
||||||
return threadPool;
|
return threadPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(int delay)
|
public void stop(int delay)
|
||||||
{
|
{
|
||||||
cleanUpContexts();
|
cleanUpContexts();
|
||||||
cleanUpConnectors();
|
cleanUpConnectors();
|
||||||
|
|
||||||
if (_serverShared) return;
|
if (_serverShared) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_server.stop();
|
_server.stop();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUpContexts()
|
private void cleanUpContexts()
|
||||||
{
|
{
|
||||||
for (Map.Entry<String, JettyHttpContext> stringJettyHttpContextEntry : _contexts.entrySet())
|
for (Map.Entry<String, JettyHttpContext> stringJettyHttpContextEntry : _contexts.entrySet())
|
||||||
{
|
{
|
||||||
JettyHttpContext context = stringJettyHttpContextEntry.getValue();
|
JettyHttpContext context = stringJettyHttpContextEntry.getValue();
|
||||||
_server.removeBean(context.getJettyContextHandler());
|
_server.removeBean(context.getJettyContextHandler());
|
||||||
}
|
}
|
||||||
_contexts.clear();
|
_contexts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUpConnectors()
|
private void cleanUpConnectors()
|
||||||
{
|
{
|
||||||
for (Map.Entry<String, Connector> stringConnectorEntry : _connectors.entrySet())
|
for (Map.Entry<String, Connector> stringConnectorEntry : _connectors.entrySet())
|
||||||
{
|
{
|
||||||
Connector connector = stringConnectorEntry.getValue();
|
Connector connector = stringConnectorEntry.getValue();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connector.stop();
|
connector.stop();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.warn(ex);
|
LOG.warn(ex);
|
||||||
}
|
}
|
||||||
_server.removeConnector(connector);
|
_server.removeConnector(connector);
|
||||||
}
|
}
|
||||||
_connectors.clear();
|
_connectors.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpContext createContext(String path, HttpHandler httpHandler)
|
public HttpContext createContext(String path, HttpHandler httpHandler)
|
||||||
{
|
{
|
||||||
checkIfContextIsFree(path);
|
checkIfContextIsFree(path);
|
||||||
|
|
||||||
JettyHttpContext context = new JettyHttpContext(this, path, httpHandler);
|
JettyHttpContext context = new JettyHttpContext(this, path, httpHandler);
|
||||||
HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler();
|
HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler();
|
||||||
|
|
||||||
ContextHandlerCollection chc = findContextHandlerCollection(_server.getHandlers());
|
ContextHandlerCollection chc = findContextHandlerCollection(_server.getHandlers());
|
||||||
if (chc == null)
|
if (chc == null)
|
||||||
throw new RuntimeException("could not find ContextHandlerCollection, you must configure one");
|
throw new RuntimeException("could not find ContextHandlerCollection, you must configure one");
|
||||||
|
|
||||||
chc.addHandler(jettyContextHandler);
|
chc.addHandler(jettyContextHandler);
|
||||||
_contexts.put(path, context);
|
_contexts.put(path, context);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContextHandlerCollection findContextHandlerCollection(Handler[] handlers)
|
private ContextHandlerCollection findContextHandlerCollection(Handler[] handlers)
|
||||||
{
|
{
|
||||||
if (handlers == null)
|
if (handlers == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (Handler handler : handlers)
|
for (Handler handler : handlers)
|
||||||
{
|
{
|
||||||
if (handler instanceof ContextHandlerCollection)
|
if (handler instanceof ContextHandlerCollection)
|
||||||
{
|
{
|
||||||
return (ContextHandlerCollection) handler;
|
return (ContextHandlerCollection) handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler instanceof HandlerCollection)
|
if (handler instanceof HandlerCollection)
|
||||||
{
|
{
|
||||||
HandlerCollection hc = (HandlerCollection) handler;
|
HandlerCollection hc = (HandlerCollection) handler;
|
||||||
ContextHandlerCollection chc = findContextHandlerCollection(hc.getHandlers());
|
ContextHandlerCollection chc = findContextHandlerCollection(hc.getHandlers());
|
||||||
if (chc != null)
|
if (chc != null)
|
||||||
return chc;
|
return chc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfContextIsFree(String path)
|
private void checkIfContextIsFree(String path)
|
||||||
{
|
{
|
||||||
Handler serverHandler = _server.getHandler();
|
Handler serverHandler = _server.getHandler();
|
||||||
if (serverHandler instanceof ContextHandler)
|
if (serverHandler instanceof ContextHandler)
|
||||||
{
|
{
|
||||||
ContextHandler ctx = (ContextHandler) serverHandler;
|
ContextHandler ctx = (ContextHandler) serverHandler;
|
||||||
if (ctx.getContextPath().equals(path))
|
if (ctx.getContextPath().equals(path))
|
||||||
throw new RuntimeException("another context already bound to path " + path);
|
throw new RuntimeException("another context already bound to path " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler[] handlers = _server.getHandlers();
|
Handler[] handlers = _server.getHandlers();
|
||||||
if (handlers == null) return;
|
if (handlers == null) return;
|
||||||
|
|
||||||
for (Handler handler : handlers)
|
for (Handler handler : handlers)
|
||||||
{
|
{
|
||||||
if (handler instanceof ContextHandler) {
|
if (handler instanceof ContextHandler) {
|
||||||
ContextHandler ctx = (ContextHandler) handler;
|
ContextHandler ctx = (ContextHandler) handler;
|
||||||
if (ctx.getContextPath().equals(path))
|
if (ctx.getContextPath().equals(path))
|
||||||
throw new RuntimeException("another context already bound to path " + path);
|
throw new RuntimeException("another context already bound to path " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpContext createContext(String path)
|
public HttpContext createContext(String path)
|
||||||
{
|
{
|
||||||
return createContext(path, null);
|
return createContext(path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeContext(String path) throws IllegalArgumentException
|
public void removeContext(String path) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
JettyHttpContext context = _contexts.remove(path);
|
JettyHttpContext context = _contexts.remove(path);
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
_server.removeBean(context.getJettyContextHandler());
|
_server.removeBean(context.getJettyContextHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeContext(HttpContext context)
|
public void removeContext(HttpContext context)
|
||||||
{
|
{
|
||||||
removeContext(context.getPath());
|
removeContext(context.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class JettyHttpServerProvider extends HttpServerProvider
|
||||||
|
|
||||||
public static void setServer(Server server)
|
public static void setServer(Server server)
|
||||||
{
|
{
|
||||||
_server = server;
|
_server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ public class JettyHttpServerProvider extends HttpServerProvider
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Server server = _server;
|
Server server = _server;
|
||||||
boolean shared = true;
|
boolean shared = true;
|
||||||
|
|
||||||
if (server == null)
|
if (server == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class JAASLoginService extends AbstractLifeCycle implements LoginService
|
||||||
}
|
}
|
||||||
else if (callback instanceof RequestParameterCallback)
|
else if (callback instanceof RequestParameterCallback)
|
||||||
{
|
{
|
||||||
HttpChannel channel = HttpChannel.getCurrentHttpChannel();
|
HttpChannel channel = HttpChannel.getCurrentHttpChannel();
|
||||||
|
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -82,23 +82,23 @@ public class ConnectorServer extends AbstractLifeCycle
|
||||||
public ConnectorServer(JMXServiceURL svcUrl, Map<String,?> environment, String name)
|
public ConnectorServer(JMXServiceURL svcUrl, Map<String,?> environment, String name)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String urlPath = svcUrl.getURLPath();
|
String urlPath = svcUrl.getURLPath();
|
||||||
int idx = urlPath.indexOf("rmi://");
|
int idx = urlPath.indexOf("rmi://");
|
||||||
if (idx > 0)
|
if (idx > 0)
|
||||||
{
|
{
|
||||||
String hostPort = urlPath.substring(idx+6, urlPath.indexOf('/', idx+6));
|
String hostPort = urlPath.substring(idx+6, urlPath.indexOf('/', idx+6));
|
||||||
String regHostPort = startRegistry(hostPort);
|
String regHostPort = startRegistry(hostPort);
|
||||||
if (regHostPort != null) {
|
if (regHostPort != null) {
|
||||||
urlPath = urlPath.replace(hostPort,regHostPort);
|
urlPath = urlPath.replace(hostPort,regHostPort);
|
||||||
svcUrl = new JMXServiceURL(svcUrl.getProtocol(), svcUrl.getHost(), svcUrl.getPort(), urlPath);
|
svcUrl = new JMXServiceURL(svcUrl.getProtocol(), svcUrl.getHost(), svcUrl.getPort(), urlPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
|
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
_connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(svcUrl, environment, mbeanServer);
|
_connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(svcUrl, environment, mbeanServer);
|
||||||
mbeanServer.registerMBean(_connectorServer,new ObjectName(name));
|
mbeanServer.registerMBean(_connectorServer,new ObjectName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
}
|
}
|
||||||
public void setContainerIncludeJarPattern(String pattern)
|
public void setContainerIncludeJarPattern(String pattern)
|
||||||
{
|
{
|
||||||
_containerIncludeJarPattern = pattern;
|
_containerIncludeJarPattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContainerIncludeJarPattern()
|
public String getContainerIncludeJarPattern()
|
||||||
|
@ -150,7 +150,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
|
|
||||||
public String getWebInfIncludeJarPattern()
|
public String getWebInfIncludeJarPattern()
|
||||||
{
|
{
|
||||||
return _webInfIncludeJarPattern;
|
return _webInfIncludeJarPattern;
|
||||||
}
|
}
|
||||||
public void setWebInfIncludeJarPattern(String pattern)
|
public void setWebInfIncludeJarPattern(String pattern)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ServiceConnection
|
||||||
*/
|
*/
|
||||||
public String getServiceUrl()
|
public String getServiceUrl()
|
||||||
{
|
{
|
||||||
return _serviceUrl;
|
return _serviceUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class NoSqlSession extends MemSession
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public Object getVersion()
|
public Object getVersion()
|
||||||
{
|
{
|
||||||
return _version;
|
return _version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -654,7 +654,7 @@ public class MongoSessionManager extends NoSqlSessionManager
|
||||||
/*------------------------------------------------------------ */
|
/*------------------------------------------------------------ */
|
||||||
private String getContextKey()
|
private String getContextKey()
|
||||||
{
|
{
|
||||||
return __CONTEXT + "." + _contextId;
|
return __CONTEXT + "." + _contextId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------ */
|
/*------------------------------------------------------------ */
|
||||||
|
@ -664,7 +664,7 @@ public class MongoSessionManager extends NoSqlSessionManager
|
||||||
*/
|
*/
|
||||||
private String getContextAttributeKey(String attr)
|
private String getContextAttributeKey(String attr)
|
||||||
{
|
{
|
||||||
return getContextKey()+ "." + attr;
|
return getContextKey()+ "." + attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ManagedOperation(value="purge invalid sessions in the session store based on normal criteria", impact="ACTION")
|
@ManagedOperation(value="purge invalid sessions in the session store based on normal criteria", impact="ACTION")
|
||||||
|
|
|
@ -30,16 +30,16 @@ import javax.servlet.http.HttpServlet;
|
||||||
*/
|
*/
|
||||||
public class HttpServiceErrorHandlerHelper
|
public class HttpServiceErrorHandlerHelper
|
||||||
{
|
{
|
||||||
private static HttpServlet _customErrorHandler;
|
private static HttpServlet _customErrorHandler;
|
||||||
|
|
||||||
public static HttpServlet getCustomErrorHandler()
|
public static HttpServlet getCustomErrorHandler()
|
||||||
{
|
{
|
||||||
return _customErrorHandler;
|
return _customErrorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHttpServiceErrorHandler(HttpServlet servlet)
|
public static void setHttpServiceErrorHandler(HttpServlet servlet)
|
||||||
{
|
{
|
||||||
_customErrorHandler = servlet;
|
_customErrorHandler = servlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,46 +35,46 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||||
public class HttpServiceErrorPageErrorHandler extends ErrorPageErrorHandler
|
public class HttpServiceErrorPageErrorHandler extends ErrorPageErrorHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
private static HttpServiceErrorPageErrorHandler INSTANCE;
|
private static HttpServiceErrorPageErrorHandler INSTANCE;
|
||||||
|
|
||||||
public static HttpServiceErrorPageErrorHandler getInstance()
|
public static HttpServiceErrorPageErrorHandler getInstance()
|
||||||
{
|
{
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpServiceErrorPageErrorHandler()
|
public HttpServiceErrorPageErrorHandler()
|
||||||
{
|
{
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(String target, Request baseRequest,
|
public void handle(String target, Request baseRequest,
|
||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (HttpServiceErrorHandlerHelper.getCustomErrorHandler() != null)
|
if (HttpServiceErrorHandlerHelper.getCustomErrorHandler() != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpServiceErrorHandlerHelper.getCustomErrorHandler().service(request, response);
|
HttpServiceErrorHandlerHelper.getCustomErrorHandler().service(request, response);
|
||||||
}
|
}
|
||||||
catch (ServletException e)
|
catch (ServletException e)
|
||||||
{
|
{
|
||||||
//well
|
//well
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!response.isCommitted())
|
if (!response.isCommitted())
|
||||||
{
|
{
|
||||||
super.handle(target, baseRequest, request, response);
|
super.handle(target, baseRequest, request, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStop() throws Exception
|
protected void doStop() throws Exception
|
||||||
{
|
{
|
||||||
INSTANCE = null;
|
INSTANCE = null;
|
||||||
super.doStop();
|
super.doStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class OverlayServer
|
||||||
server.setStopAtShutdown(true);
|
server.setStopAtShutdown(true);
|
||||||
//server.setSendServerVersion(true);
|
//server.setSendServerVersion(true);
|
||||||
|
|
||||||
// Uncomment to work with JNDI examples
|
// Uncomment to work with JNDI examples
|
||||||
// new org.eclipse.jetty.plus.jndi.Transaction(new com.atomikos.icatch.jta.UserTransactionImp());
|
// new org.eclipse.jetty.plus.jndi.Transaction(new com.atomikos.icatch.jta.UserTransactionImp());
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class ContainerInitializer
|
||||||
interested.add(c.getName());
|
interested.add(c.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format("ContainerInitializer{%s,interested=%s,applicable=%s,annotated=%s}",_target.getClass().getName(),interested,_applicableTypeNames,_annotatedTypeNames);
|
return String.format("ContainerInitializer{%s,interested=%s,applicable=%s,annotated=%s}",_target.getClass().getName(),interested,_applicableTypeNames,_annotatedTypeNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolveClasses(WebAppContext context, Map<String, Set<String>> classMap)
|
public void resolveClasses(WebAppContext context, Map<String, Set<String>> classMap)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class GatewayServer extends Server
|
||||||
|
|
||||||
public GatewayServer()
|
public GatewayServer()
|
||||||
{
|
{
|
||||||
this("",DFT_EXT_PATH,DFT_CONNECT_PATH,new StandardTargetIdRetriever());
|
this("",DFT_EXT_PATH,DFT_CONNECT_PATH,new StandardTargetIdRetriever());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GatewayServer(String contextPath, String externalServletPath,String gatewayServletPath, TargetIdRetriever targetIdRetriever)
|
public GatewayServer(String contextPath, String externalServletPath,String gatewayServletPath, TargetIdRetriever targetIdRetriever)
|
||||||
|
@ -145,7 +145,7 @@ public class GatewayServer extends Server
|
||||||
|
|
||||||
public Gateway getGateway()
|
public Gateway getGateway()
|
||||||
{
|
{
|
||||||
return gateway;
|
return gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServletHolder getExternalServlet()
|
public ServletHolder getExternalServlet()
|
||||||
|
|
|
@ -331,28 +331,28 @@ public class DeferredAuthentication implements Authentication.Deferred
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getHeaderNames()
|
public Collection<String> getHeaderNames()
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHeader(String arg0)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> getHeaders(String arg0)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatus()
|
public String getHeader(String arg0)
|
||||||
{
|
{
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> getHeaders(String arg0)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatus()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
|
||||||
*/
|
*/
|
||||||
public SpnegoAuthenticator( String authMethod )
|
public SpnegoAuthenticator( String authMethod )
|
||||||
{
|
{
|
||||||
_authMethod = authMethod;
|
_authMethod = authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,10 +77,10 @@ public class SpnegoAuthenticator extends LoginAuthenticator
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (DeferredAuthentication.isDeferred(res))
|
if (DeferredAuthentication.isDeferred(res))
|
||||||
{
|
{
|
||||||
return Authentication.UNAUTHENTICATED;
|
return Authentication.UNAUTHENTICATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("SpengoAuthenticator: sending challenge");
|
LOG.debug("SpengoAuthenticator: sending challenge");
|
||||||
res.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), HttpHeader.NEGOTIATE.asString());
|
res.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), HttpHeader.NEGOTIATE.asString());
|
||||||
|
|
|
@ -173,64 +173,64 @@ public class ContextHandlerCollection extends HandlerCollection
|
||||||
{
|
{
|
||||||
Handler[] handlers = getHandlers();
|
Handler[] handlers = getHandlers();
|
||||||
if (handlers==null || handlers.length==0)
|
if (handlers==null || handlers.length==0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HttpChannelState async = baseRequest.getHttpChannelState();
|
HttpChannelState async = baseRequest.getHttpChannelState();
|
||||||
if (async.isAsync())
|
if (async.isAsync())
|
||||||
{
|
{
|
||||||
ContextHandler context=async.getContextHandler();
|
ContextHandler context=async.getContextHandler();
|
||||||
if (context!=null)
|
if (context!=null)
|
||||||
{
|
{
|
||||||
Handler branch = _contextBranches.get(context);
|
Handler branch = _contextBranches.get(context);
|
||||||
|
|
||||||
if (branch==null)
|
|
||||||
context.handle(target,baseRequest,request, response);
|
|
||||||
else
|
|
||||||
branch.handle(target, baseRequest, request, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// data structure which maps a request to a context; first-best match wins
|
|
||||||
// { context path => [ context ] }
|
|
||||||
// }
|
|
||||||
if (target.startsWith("/"))
|
|
||||||
{
|
|
||||||
int limit = target.length()-1;
|
|
||||||
|
|
||||||
while (limit>=0)
|
|
||||||
{
|
|
||||||
// Get best match
|
|
||||||
Map.Entry<String,Branch[]> branches = _pathBranches.getBest(target,1,limit);
|
|
||||||
|
|
||||||
|
|
||||||
if (branches==null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
int l=branches.getKey().length();
|
if (branch==null)
|
||||||
if (l==1 || target.length()==l || target.charAt(l)=='/')
|
context.handle(target,baseRequest,request, response);
|
||||||
{
|
else
|
||||||
for (Branch branch : branches.getValue())
|
branch.handle(target, baseRequest, request, response);
|
||||||
{
|
return;
|
||||||
branch.getHandler().handle(target,baseRequest, request, response);
|
}
|
||||||
if (baseRequest.isHandled())
|
}
|
||||||
return;
|
|
||||||
}
|
// data structure which maps a request to a context; first-best match wins
|
||||||
}
|
// { context path => [ context ] }
|
||||||
|
// }
|
||||||
limit=l-2;
|
if (target.startsWith("/"))
|
||||||
}
|
{
|
||||||
}
|
int limit = target.length()-1;
|
||||||
else
|
|
||||||
{
|
while (limit>=0)
|
||||||
|
{
|
||||||
|
// Get best match
|
||||||
|
Map.Entry<String,Branch[]> branches = _pathBranches.getBest(target,1,limit);
|
||||||
|
|
||||||
|
|
||||||
|
if (branches==null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int l=branches.getKey().length();
|
||||||
|
if (l==1 || target.length()==l || target.charAt(l)=='/')
|
||||||
|
{
|
||||||
|
for (Branch branch : branches.getValue())
|
||||||
|
{
|
||||||
|
branch.getHandler().handle(target,baseRequest, request, response);
|
||||||
|
if (baseRequest.isHandled())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
limit=l-2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// This may not work in all circumstances... but then I think it should never be called
|
// This may not work in all circumstances... but then I think it should never be called
|
||||||
for (int i=0;i<handlers.length;i++)
|
for (int i=0;i<handlers.length;i++)
|
||||||
{
|
{
|
||||||
handlers[i].handle(target,baseRequest, request, response);
|
handlers[i].handle(target,baseRequest, request, response);
|
||||||
if ( baseRequest.isHandled())
|
if ( baseRequest.isHandled())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -63,9 +63,9 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
||||||
@Override
|
@Override
|
||||||
public void testFullMethod() throws Exception
|
public void testFullMethod() throws Exception
|
||||||
{
|
{
|
||||||
// Don't run on Windows (buggy JVM)
|
// Don't run on Windows (buggy JVM)
|
||||||
Assume.assumeTrue(!OS.IS_WINDOWS);
|
Assume.assumeTrue(!OS.IS_WINDOWS);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
super.testFullMethod();
|
super.testFullMethod();
|
||||||
|
@ -79,8 +79,8 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
||||||
@Override
|
@Override
|
||||||
public void testFullURI() throws Exception
|
public void testFullURI() throws Exception
|
||||||
{
|
{
|
||||||
// Don't run on Windows (buggy JVM)
|
// Don't run on Windows (buggy JVM)
|
||||||
Assume.assumeTrue(!OS.IS_WINDOWS);
|
Assume.assumeTrue(!OS.IS_WINDOWS);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
super.testFullURI();
|
super.testFullURI();
|
||||||
|
|
|
@ -66,19 +66,19 @@ public class FilterMapping implements Dumpable
|
||||||
*/
|
*/
|
||||||
public static int dispatch(DispatcherType type)
|
public static int dispatch(DispatcherType type)
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case REQUEST:
|
case REQUEST:
|
||||||
return REQUEST;
|
return REQUEST;
|
||||||
case ASYNC:
|
case ASYNC:
|
||||||
return ASYNC;
|
return ASYNC;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
return FORWARD;
|
return FORWARD;
|
||||||
case INCLUDE:
|
case INCLUDE:
|
||||||
return INCLUDE;
|
return INCLUDE;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException(type.toString());
|
throw new IllegalArgumentException(type.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ public class FilterMapping implements Dumpable
|
||||||
*/
|
*/
|
||||||
boolean appliesTo(int type)
|
boolean appliesTo(int type)
|
||||||
{
|
{
|
||||||
if (_dispatches==0)
|
if (_dispatches==0)
|
||||||
return type==REQUEST || type==ASYNC && _holder.isAsyncSupported();
|
return type==REQUEST || type==ASYNC && _holder.isAsyncSupported();
|
||||||
return (_dispatches&type)!=0;
|
return (_dispatches&type)!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class Invoker extends HttpServlet
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected void service(HttpServletRequest request, HttpServletResponse response)
|
protected void service(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
// Get the requested path and info
|
// Get the requested path and info
|
||||||
boolean included=false;
|
boolean included=false;
|
||||||
|
|
|
@ -288,9 +288,9 @@ public class ServletContextHandler extends ContextHandler
|
||||||
decorator.decorate(holder.getListener());
|
decorator.decorate(holder.getListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.startContext();
|
super.startContext();
|
||||||
|
|
||||||
// OK to Initialize servlet handler now that all relevant object trees have been started
|
// OK to Initialize servlet handler now that all relevant object trees have been started
|
||||||
|
|
|
@ -751,23 +751,23 @@ public class ServletHandler extends ScopedHandler
|
||||||
final Map<String,FilterChain> cache=_chainCache[dispatch];
|
final Map<String,FilterChain> cache=_chainCache[dispatch];
|
||||||
final Queue<String> lru=_chainLRU[dispatch];
|
final Queue<String> lru=_chainLRU[dispatch];
|
||||||
|
|
||||||
// Do we have too many cached chains?
|
// Do we have too many cached chains?
|
||||||
while (_maxFilterChainsCacheSize>0 && cache.size()>=_maxFilterChainsCacheSize)
|
while (_maxFilterChainsCacheSize>0 && cache.size()>=_maxFilterChainsCacheSize)
|
||||||
{
|
{
|
||||||
// The LRU list is not atomic with the cache map, so be prepared to invalidate if
|
// The LRU list is not atomic with the cache map, so be prepared to invalidate if
|
||||||
// a key is not found to delete.
|
// a key is not found to delete.
|
||||||
// Delete by LRU (where U==created)
|
// Delete by LRU (where U==created)
|
||||||
String k=lru.poll();
|
String k=lru.poll();
|
||||||
if (k==null)
|
if (k==null)
|
||||||
{
|
{
|
||||||
cache.clear();
|
cache.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cache.remove(k);
|
cache.remove(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.put(key,chain);
|
cache.put(key,chain);
|
||||||
lru.add(key);
|
lru.add(key);
|
||||||
}
|
}
|
||||||
else if (filters.size() > 0)
|
else if (filters.size() > 0)
|
||||||
chain = new Chain(baseRequest,filters, servletHolder);
|
chain = new Chain(baseRequest,filters, servletHolder);
|
||||||
|
|
|
@ -570,7 +570,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
private void initServlet()
|
private void initServlet()
|
||||||
throws ServletException
|
throws ServletException
|
||||||
{
|
{
|
||||||
Object old_run_as = null;
|
Object old_run_as = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class AsyncContextDispatchWithQueryStrings
|
public class AsyncContextDispatchWithQueryStrings
|
||||||
{
|
{
|
||||||
|
|
||||||
private Server _server = new Server();
|
private Server _server = new Server();
|
||||||
private ServletContextHandler _contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
|
private ServletContextHandler _contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
|
||||||
private LocalConnector _connector = new LocalConnector(_server);
|
private LocalConnector _connector = new LocalConnector(_server);
|
||||||
|
@ -73,7 +72,8 @@ public class AsyncContextDispatchWithQueryStrings
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleDispatchesWithNewQueryStrings() throws Exception {
|
public void testMultipleDispatchesWithNewQueryStrings() throws Exception
|
||||||
|
{
|
||||||
String request =
|
String request =
|
||||||
"GET /initialCall?initialParam=right HTTP/1.1\r\n" +
|
"GET /initialCall?initialParam=right HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
|
@ -84,7 +84,8 @@ public class AsyncContextDispatchWithQueryStrings
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception
|
||||||
|
{
|
||||||
_server.stop();
|
_server.stop();
|
||||||
_server.join();
|
_server.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,15 +49,15 @@ public class WelcomeFilter implements Filter
|
||||||
public void init(FilterConfig filterConfig)
|
public void init(FilterConfig filterConfig)
|
||||||
{
|
{
|
||||||
welcome=filterConfig.getInitParameter("welcome");
|
welcome=filterConfig.getInitParameter("welcome");
|
||||||
if (welcome==null)
|
if (welcome==null)
|
||||||
welcome="index.html";
|
welcome="index.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void doFilter(ServletRequest request,
|
public void doFilter(ServletRequest request,
|
||||||
ServletResponse response,
|
ServletResponse response,
|
||||||
FilterChain chain)
|
FilterChain chain)
|
||||||
throws IOException, ServletException
|
throws IOException, ServletException
|
||||||
{
|
{
|
||||||
String path=((HttpServletRequest)request).getServletPath();
|
String path=((HttpServletRequest)request).getServletPath();
|
||||||
if (welcome!=null && path.endsWith("/"))
|
if (welcome!=null && path.endsWith("/"))
|
||||||
|
|
|
@ -57,6 +57,6 @@ public class CloseableDoSFilterTest extends AbstractDoSFilterTest
|
||||||
public void testUnresponsiveClient() throws Exception
|
public void testUnresponsiveClient() throws Exception
|
||||||
{
|
{
|
||||||
// TODO work out why this intermittently fails
|
// TODO work out why this intermittently fails
|
||||||
LOG.warn("Ignored Closeable testUnresponsiveClient");
|
LOG.warn("Ignored Closeable testUnresponsiveClient");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -894,9 +894,9 @@ public class StartArgs
|
||||||
// only add non-duplicates
|
// only add non-duplicates
|
||||||
if (!propertyFileRefs.contains(arg))
|
if (!propertyFileRefs.contains(arg))
|
||||||
{
|
{
|
||||||
propertyFileRefs.add(arg);
|
propertyFileRefs.add(arg);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anything else is unrecognized
|
// Anything else is unrecognized
|
||||||
|
@ -938,7 +938,7 @@ public class StartArgs
|
||||||
Path propertyFile = baseHome.getPath(propertyFileRef);
|
Path propertyFile = baseHome.getPath(propertyFileRef);
|
||||||
if (!FS.exists(propertyFile))
|
if (!FS.exists(propertyFile))
|
||||||
{
|
{
|
||||||
propertyFile = baseHome.getPath("etc/" + propertyFileRef);
|
propertyFile = baseHome.getPath("etc/" + propertyFileRef);
|
||||||
}
|
}
|
||||||
addUniquePropertyFile(propertyFileRef,propertyFile);
|
addUniquePropertyFile(propertyFileRef,propertyFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,7 +549,7 @@ public abstract class Resource implements ResourceFactory, Closeable
|
||||||
buf.append("</TD></TR>");
|
buf.append("</TD></TR>");
|
||||||
}
|
}
|
||||||
buf.append("</TABLE>\n");
|
buf.append("</TABLE>\n");
|
||||||
buf.append("</BODY></HTML>\n");
|
buf.append("</BODY></HTML>\n");
|
||||||
|
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class URLEncodedTest
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@Test
|
@Test
|
||||||
public void testUrlEncodedStream()
|
public void testUrlEncodedStream()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String [][] charsets = new String[][]
|
String [][] charsets = new String[][]
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,9 +124,9 @@ public class ResourceTest
|
||||||
__userURL=uri.toURL();
|
__userURL=uri.toURL();
|
||||||
|
|
||||||
__userURL = MavenTestingUtils.getTestResourcesDir().toURI().toURL();
|
__userURL = MavenTestingUtils.getTestResourcesDir().toURI().toURL();
|
||||||
FilePermission perm = (FilePermission) __userURL.openConnection().getPermission();
|
FilePermission perm = (FilePermission) __userURL.openConnection().getPermission();
|
||||||
__userDir = new File(perm.getName()).getCanonicalPath() + File.separatorChar;
|
__userDir = new File(perm.getName()).getCanonicalPath() + File.separatorChar;
|
||||||
__relDir = "src/test/resources/".replace('/', File.separatorChar);
|
__relDir = "src/test/resources/".replace('/', File.separatorChar);
|
||||||
|
|
||||||
//System.err.println("User Dir="+__userDir);
|
//System.err.println("User Dir="+__userDir);
|
||||||
//System.err.println("Rel Dir="+__relDir);
|
//System.err.println("Rel Dir="+__relDir);
|
||||||
|
|
|
@ -75,10 +75,10 @@ public class FragmentConfiguration extends AbstractConfiguration
|
||||||
{
|
{
|
||||||
for (Resource key : frags.keySet())
|
for (Resource key : frags.keySet())
|
||||||
{
|
{
|
||||||
if (key.isDirectory()) //tolerate the case where the library is a directory, not a jar. useful for OSGi for example
|
if (key.isDirectory()) //tolerate the case where the library is a directory, not a jar. useful for OSGi for example
|
||||||
{
|
{
|
||||||
metaData.addFragment(key, frags.get(key));
|
metaData.addFragment(key, frags.get(key));
|
||||||
}
|
}
|
||||||
else //the standard case: a jar most likely inside WEB-INF/lib
|
else //the standard case: a jar most likely inside WEB-INF/lib
|
||||||
{
|
{
|
||||||
metaData.addFragment(key, frags.get(key));
|
metaData.addFragment(key, frags.get(key));
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class WebAppClassLoader extends URLClassLoader
|
||||||
* with '/'.
|
* with '/'.
|
||||||
*/
|
*/
|
||||||
public void addClassPath(String classPath)
|
public void addClassPath(String classPath)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (classPath == null)
|
if (classPath == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -914,7 +914,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected void loadConfigurations()
|
protected void loadConfigurations()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
//if the configuration instances have been set explicitly, use them
|
//if the configuration instances have been set explicitly, use them
|
||||||
if (_configurations.size()>0)
|
if (_configurations.size()>0)
|
||||||
|
|
|
@ -67,8 +67,8 @@ public class ClientConnectTest
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if(!errorClass.isInstance(cause))
|
if(!errorClass.isInstance(cause))
|
||||||
{
|
{
|
||||||
cause.printStackTrace(System.err);
|
cause.printStackTrace(System.err);
|
||||||
Assert.assertThat("ExecutionException.cause",cause,instanceOf(errorClass));
|
Assert.assertThat("ExecutionException.cause",cause,instanceOf(errorClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate websocket captured cause
|
// Validate websocket captured cause
|
||||||
|
@ -359,15 +359,15 @@ public class ClientConnectTest
|
||||||
}
|
}
|
||||||
catch (ExecutionException e)
|
catch (ExecutionException e)
|
||||||
{
|
{
|
||||||
if(OS.IS_WINDOWS)
|
if(OS.IS_WINDOWS)
|
||||||
{
|
{
|
||||||
// On windows, this is a SocketTimeoutException
|
// On windows, this is a SocketTimeoutException
|
||||||
assertExpectedError(e, wsocket, SocketTimeoutException.class);
|
assertExpectedError(e, wsocket, SocketTimeoutException.class);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Expected path - java.net.ConnectException
|
// Expected path - java.net.ConnectException
|
||||||
assertExpectedError(e,wsocket,ConnectException.class);
|
assertExpectedError(e,wsocket,ConnectException.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class TestConfiguration extends HashMap<String,Object>
|
||||||
|
|
||||||
public void setPropertyTest(int value)
|
public void setPropertyTest(int value)
|
||||||
{
|
{
|
||||||
propValue=value;
|
propValue=value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestConfiguration getNested()
|
public TestConfiguration getNested()
|
||||||
|
|
|
@ -86,7 +86,7 @@ public abstract class RFC2616BaseTest
|
||||||
|
|
||||||
public static void setUpServer(TestableJettyServer testableserver, Class<?> testclazz) throws Exception
|
public static void setUpServer(TestableJettyServer testableserver, Class<?> testclazz) throws Exception
|
||||||
{
|
{
|
||||||
File testWorkDir = MavenTestingUtils.getTargetTestingDir(testclazz.getName());
|
File testWorkDir = MavenTestingUtils.getTargetTestingDir(testclazz.getName());
|
||||||
FS.ensureDirExists(testWorkDir);
|
FS.ensureDirExists(testWorkDir);
|
||||||
|
|
||||||
System.setProperty("java.io.tmpdir",testWorkDir.getAbsolutePath());
|
System.setProperty("java.io.tmpdir",testWorkDir.getAbsolutePath());
|
||||||
|
|
|
@ -34,21 +34,21 @@ public class SessionValueSavingTest extends AbstractSessionValueSavingTest
|
||||||
return new JdbcTestServer(port,max,scavenge);
|
return new JdbcTestServer(port,max,scavenge);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSessionValueSaving() throws Exception
|
public void testSessionValueSaving() throws Exception
|
||||||
{
|
{
|
||||||
super.testSessionValueSaving();
|
super.testSessionValueSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
|
DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
|
||||||
}
|
}
|
||||||
catch( SQLException expected )
|
catch( SQLException expected )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,8 @@ public abstract class AbstractSessionValueSavingTest
|
||||||
System.out.println("not init call " + session);
|
System.out.println("not init call " + session);
|
||||||
if (session!=null)
|
if (session!=null)
|
||||||
{
|
{
|
||||||
long value = System.currentTimeMillis();
|
long value = System.currentTimeMillis();
|
||||||
System.out.println("Setting test to : " + value);
|
System.out.println("Setting test to : " + value);
|
||||||
session.setAttribute("test", value);
|
session.setAttribute("test", value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -148,14 +148,14 @@ public abstract class AbstractSessionValueSavingTest
|
||||||
|
|
||||||
private void sendResult(HttpSession session, PrintWriter writer)
|
private void sendResult(HttpSession session, PrintWriter writer)
|
||||||
{
|
{
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
writer.print(session.getAttribute("test"));
|
writer.print(session.getAttribute("test"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
writer.print(0);
|
writer.print(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ public class Counter implements java.io.Serializable
|
||||||
|
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLast(String uri) {
|
public void setLast(String uri) {
|
||||||
|
|
|
@ -50,22 +50,22 @@ public class DateTag extends BodyTagSupport
|
||||||
public void doInitBody() throws JspException {}
|
public void doInitBody() throws JspException {}
|
||||||
|
|
||||||
public int doAfterBody() throws JspException {
|
public int doAfterBody() throws JspException {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SimpleDateFormat format = new SimpleDateFormat(body.getString());
|
SimpleDateFormat format = new SimpleDateFormat(body.getString());
|
||||||
format.setTimeZone(TimeZone.getTimeZone(tz));
|
format.setTimeZone(TimeZone.getTimeZone(tz));
|
||||||
body.getEnclosingWriter().write(format.format(new Date()));
|
body.getEnclosingWriter().write(format.format(new Date()));
|
||||||
return SKIP_BODY;
|
return SKIP_BODY;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw new JspTagException(ex.toString());
|
throw new JspTagException(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release()
|
public void release()
|
||||||
{
|
{
|
||||||
body=null;
|
body=null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,16 +68,16 @@ public class Dump extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException
|
public void init(ServletConfig config) throws ServletException
|
||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
|
|
||||||
if (config.getInitParameter("unavailable")!=null && !fixed)
|
if (config.getInitParameter("unavailable")!=null && !fixed)
|
||||||
{
|
{
|
||||||
|
|
||||||
fixed=true;
|
fixed=true;
|
||||||
throw new UnavailableException("Unavailable test",Integer.parseInt(config.getInitParameter("unavailable")));
|
throw new UnavailableException("Unavailable test",Integer.parseInt(config.getInitParameter("unavailable")));
|
||||||
}
|
}
|
||||||
|
|
||||||
_timer=new Timer(true);
|
_timer=new Timer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -118,7 +118,7 @@ public class Dump extends HttpServlet
|
||||||
}
|
}
|
||||||
catch(ServletException se)
|
catch(ServletException se)
|
||||||
{
|
{
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class HelloWorld extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException
|
public void init(ServletConfig config) throws ServletException
|
||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class LoginServlet extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException
|
public void init(ServletConfig config) throws ServletException
|
||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class RegTest extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException
|
public void init(ServletConfig config) throws ServletException
|
||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SecureModeServlet extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException
|
public void init(ServletConfig config) throws ServletException
|
||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -20,9 +20,9 @@ package com.acme;
|
||||||
|
|
||||||
|
|
||||||
public class Bar {
|
public class Bar {
|
||||||
|
|
||||||
@Foo(2)
|
@Foo(2)
|
||||||
public void someMethod () {
|
public void someMethod () {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue