diff options
author | Greg Wilkins | 2015-10-26 02:04:34 +0000 |
---|---|---|
committer | Greg Wilkins | 2015-10-26 02:04:34 +0000 |
commit | 9c56b53cbec20d98e5cb05cf8d1f668fe84b95e0 (patch) | |
tree | 72ae58647b15947625bdbd5b94533f4016d0aca0 | |
parent | 298a311af952ad3ef5d1c7635deabf47bddaa1c6 (diff) | |
parent | 39768f841a90715904aa19d65145be22a68d0892 (diff) | |
download | org.eclipse.jetty.project-9c56b53.tar.gz org.eclipse.jetty.project-9c56b53.tar.xz org.eclipse.jetty.project-9c56b53.zip |
Merge branch 'master' into unix-socket
5 files changed, 161 insertions, 35 deletions
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java index e563962b6d..9fc891bc66 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java @@ -136,7 +136,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testOneExchangeViaSSL() throws Exception { startSSLServer(new ServerHandler()); @@ -167,7 +167,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testTwoExchangesViaSSL() throws Exception { startSSLServer(new ServerHandler()); @@ -210,7 +210,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testTwoConcurrentExchangesViaSSL() throws Exception { startSSLServer(new ServerHandler()); @@ -278,7 +278,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testShortIdleTimeoutOverriddenByRequest() throws Exception { // Short idle timeout for HttpClient. @@ -331,7 +331,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testProxyDown() throws Exception { startSSLServer(new ServerHandler()); @@ -363,7 +363,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testServerDown() throws Exception { startSSLServer(new ServerHandler()); @@ -395,7 +395,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) public void testProxyClosesConnection() throws Exception { startSSLServer(new ServerHandler()); @@ -429,7 +429,7 @@ public class ProxyTunnellingTest } } - @Test + @Test(timeout=60000) @Ignore("External Proxy Server no longer stable enough for testing") public void testExternalProxy() throws Exception { diff --git a/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml b/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml index 63af3c21d7..65a5dea44a 100644 --- a/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml +++ b/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml @@ -19,31 +19,29 @@ <Set name="rewriteRequestURI"><Property name="jetty.rewrite.rewriteRequestURI" deprecated="rewrite.rewriteRequestURI" default="true"/></Set> <Set name="rewritePathInfo"><Property name="jetty.rewrite.rewritePathInfo" deprecated="rewrite.rewritePathInfo" default="false"/></Set> <Set name="originalPathAttribute"><Property name="jetty.rewrite.originalPathAttribute" deprecated="rewrite.originalPathAttribute" default="requestedPath"/></Set> - </New> - <!-- Set DispatcherTypes --> - <Set name="dispatcherTypes"> - <Array type="javax.servlet.DispatcherType"> - <Item><Call class="javax.servlet.DispatcherType" name="valueOf"><Arg>REQUEST</Arg></Call></Item> - <Item><Call class="javax.servlet.DispatcherType" name="valueOf"><Arg>ASYNC</Arg></Call></Item> - </Array> - </Set> - </Set> - - - - <!-- example rule --> - <!-- - <Call name="addRule"> - <Arg> - <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule"> - <Set name="pattern">/favicon.ico</Set> - <Set name="name">Cache-Control</Set> - <Set name="value">Max-Age=3600,public</Set> - <Set name="terminating">true</Set> - </New> - </Arg> - </Call> - --> + <!-- Set DispatcherTypes --> + <Set name="dispatcherTypes"> + <Array type="javax.servlet.DispatcherType"> + <Item><Call class="javax.servlet.DispatcherType" name="valueOf"><Arg>REQUEST</Arg></Call></Item> + <Item><Call class="javax.servlet.DispatcherType" name="valueOf"><Arg>ASYNC</Arg></Call></Item> + </Array> + </Set> + + <!-- example rule --> + <!-- + <Call name="addRule"> + <Arg> + <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule"> + <Set name="pattern">/favicon.ico</Set> + <Set name="name">Cache-Control</Set> + <Set name="value">Max-Age=3600,public</Set> + <Set name="terminating">true</Set> + </New> + </Arg> + </Call> + --> + </New> + </Set> </Configure> diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java new file mode 100644 index 0000000000..b099a34810 --- /dev/null +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java @@ -0,0 +1,121 @@ +// +// ======================================================================== +// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.webapp; + +import java.io.IOException; +import java.net.URL; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jetty.util.ConcurrentHashSet; +import org.eclipse.jetty.util.annotation.ManagedObject; +import org.eclipse.jetty.util.annotation.ManagedOperation; + + +/** + * A WebAppClassLoader that caches {@link #getResource(String)} results. + * Specifically this ClassLoader caches not found classes and resources, + * which can greatly increase performance for applications that search + * for resources. + */ +@ManagedObject +public class CachingWebAppClassLoader extends WebAppClassLoader +{ + private final ConcurrentHashSet<String> _notFound = new ConcurrentHashSet<>(); + private final ConcurrentHashMap<String,URL> _cache = new ConcurrentHashMap<>(); + + public CachingWebAppClassLoader(ClassLoader parent, Context context) throws IOException + { + super(parent,context); + } + + public CachingWebAppClassLoader(Context context) throws IOException + { + super(context); + } + + @Override + public URL getResource(String name) + { + if (_notFound.contains(name)) + return null; + + URL url = _cache.get(name); + + if (name==null) + { + url = super.getResource(name); + + if (url==null) + { + _notFound.add(name); + } + else + { + _cache.putIfAbsent(name,url); + } + } + + return url; + } + + @Override + protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException + { + if (_notFound.contains(name)) + throw new ClassNotFoundException(name+": in notfound cache"); + try + { + return super.loadClass(name,resolve); + } + catch (ClassNotFoundException nfe) + { + _notFound.add(name); + throw nfe; + } + } + + @Override + protected Class<?> findClass(String name) throws ClassNotFoundException + { + if (_notFound.contains(name)) + throw new ClassNotFoundException(name+": in notfound cache"); + try + { + return super.findClass(name); + } + catch (ClassNotFoundException nfe) + { + _notFound.add(name); + throw nfe; + } + } + + @ManagedOperation + public void clearCache() + { + _cache.clear(); + _notFound.clear(); + } + + @Override + public String toString() + { + return "Caching["+super.toString()+"]"; + } +} @@ -294,7 +294,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.18.1</version> + <version>2.19</version> <configuration> <argLine>-showversion -Xmx1g -Xms1g -XX:+PrintGCDetails</argLine> <failIfNoTests>false</failIfNoTests> diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml index 0037cb4906..cae730e89d 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml @@ -11,7 +11,7 @@ directory, additional configuration may be specified and hot deployments detected. ===================================================================== --> -<Configure class="org.eclipse.jetty.webapp.WebAppContext"> +<Configure id="testWebapp" class="org.eclipse.jetty.webapp.WebAppContext"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- Required minimal context configuration : --> @@ -41,6 +41,13 @@ detected. </New> </Set> + <!-- Set Caching Classloader that improves performance on resource searching webapps --> + <Set name="classLoader"> + <New class="org.eclipse.jetty.webapp.CachingWebAppClassLoader"> + <Arg><Ref refid="testWebapp"/></Arg> + </New> + </Set> + <!-- Enable symlinks <Call name="addAliasCheck"> <Arg><New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker"/></Arg> |