From 3c0c01069046f0f8ca71643b37becd56fde9de70 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 7 Mar 2012 18:58:12 +0100 Subject: [PATCH 1/6] 373569: fix jdk7/macos ssl issue leading to SSLClostTest failures Change-Id: I7af7e71581e1e56f308a5e1ca1f8e84fcbad7413 --- .../java/org/eclipse/jetty/server/ssl/SSLCloseTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java index db9d0d71171..c55f8d077d6 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java @@ -51,16 +51,19 @@ public class SSLCloseTest extends TestCase private static AsyncEndPoint __endp; private static class CredulousTM implements TrustManager, X509TrustManager { + @Override public X509Certificate[] getAcceptedIssuers() { - return null; + return new X509Certificate[]{}; } + @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { return; } + @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { return; @@ -129,6 +132,7 @@ public class SSLCloseTest extends TestCase private static class WriteHandler extends AbstractHandler { + @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try From 511f4ea957da878e624f47be91274d57f4037e5e Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 7 Mar 2012 19:09:29 +0100 Subject: [PATCH 2/6] 373572: fix jdk7/macos ssl issue leading to ConnectHandlerSSLTest failures Change-Id: I4056d686edffe073443bb40d6f0078d9aa7a7fa6 --- .../eclipse/jetty/server/handler/ConnectHandlerSSLTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java index 07977ee2472..18e4cd25a3e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java @@ -178,22 +178,26 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest private class AlwaysTrustManager implements X509TrustManager { + @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } + @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } + @Override public X509Certificate[] getAcceptedIssuers() { - return null; + return new X509Certificate[]{}; } } private static class ServerHandler extends AbstractHandler { + @Override public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException { request.setHandled(true); From 313475576b3b7d2fba011c1cd4ab3987097ccb99 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Mar 2012 14:11:28 -0600 Subject: [PATCH 3/6] lock up spdy tests that rely on npn-boot codehaus artifact behind a profile for activation --- jetty-spdy/spdy-jetty-http-webapp/pom.xml | 92 +++++++++-------- jetty-spdy/spdy-jetty-http/pom.xml | 109 +++++++++++--------- jetty-spdy/spdy-jetty/pom.xml | 119 ++++++++++++---------- 3 files changed, 172 insertions(+), 148 deletions(-) diff --git a/jetty-spdy/spdy-jetty-http-webapp/pom.xml b/jetty-spdy/spdy-jetty-http-webapp/pom.xml index b6ffdb82aee..342d7e9a49b 100644 --- a/jetty-spdy/spdy-jetty-http-webapp/pom.xml +++ b/jetty-spdy/spdy-jetty-http-webapp/pom.xml @@ -1,48 +1,50 @@ - - - org.eclipse.jetty.spdy - spdy-parent - 7.6.2-SNAPSHOT - - - 4.0.0 - spdy-jetty-http-webapp - war - Jetty :: SPDY :: Jetty HTTP Web Application - - + + + org.eclipse.jetty.spdy + spdy-parent + 7.6.2-SNAPSHOT + + 4.0.0 + spdy-jetty-http-webapp + war + Jetty :: SPDY :: Jetty HTTP Web Application + + + + spdy-tests + - - org.mortbay.jetty - jetty-maven-plugin - ${project.version} - - 8888 - quit - - -Dlog4j.configuration=file://${basedir}/src/main/resources/log4j.properties - -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - - ${basedir}/src/main/config/jetty-spdy.xml - / - - - - org.eclipse.jetty.spdy - spdy-jetty-http - ${project.version} - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - + + org.mortbay.jetty + jetty-maven-plugin + ${project.version} + + 8888 + quit + + -Dlog4j.configuration=file://${basedir}/src/main/resources/log4j.properties + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar + + ${basedir}/src/main/config/jetty-spdy.xml + / + + + + org.eclipse.jetty.spdy + spdy-jetty-http + ${project.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + + + - - - + + + + \ No newline at end of file diff --git a/jetty-spdy/spdy-jetty-http/pom.xml b/jetty-spdy/spdy-jetty-http/pom.xml index 3e2662c1b80..704093b0beb 100644 --- a/jetty-spdy/spdy-jetty-http/pom.xml +++ b/jetty-spdy/spdy-jetty-http/pom.xml @@ -1,52 +1,63 @@ - - - org.eclipse.jetty.spdy - spdy-parent - 7.6.2-SNAPSHOT - - - 4.0.0 - spdy-jetty-http - Jetty :: SPDY :: Jetty HTTP Layer - - + + + org.eclipse.jetty.spdy + spdy-parent + 7.6.2-SNAPSHOT + + 4.0.0 + spdy-jetty-http + Jetty :: SPDY :: Jetty HTTP Layer + + + + maven-surefire-plugin + + true + + + + + + + + spdy-tests + - - maven-surefire-plugin - - - -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - - - + + maven-surefire-plugin + + + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar + + + - - - - - org.eclipse.jetty.spdy - spdy-jetty - ${project.version} - - - junit - junit - - - org.eclipse.jetty.npn - npn-api - ${project.version} - test - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - test - - - - + + + + + + org.eclipse.jetty.spdy + spdy-jetty + ${project.version} + + + junit + junit + + + org.eclipse.jetty.npn + npn-api + ${project.version} + test + + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + test + + + \ No newline at end of file diff --git a/jetty-spdy/spdy-jetty/pom.xml b/jetty-spdy/spdy-jetty/pom.xml index d1db3388970..38281949232 100644 --- a/jetty-spdy/spdy-jetty/pom.xml +++ b/jetty-spdy/spdy-jetty/pom.xml @@ -1,57 +1,68 @@ - - - org.eclipse.jetty.spdy - spdy-parent - 7.6.2-SNAPSHOT - - - 4.0.0 - spdy-jetty - Jetty :: SPDY :: Jetty Binding - - + + + org.eclipse.jetty.spdy + spdy-parent + 7.6.2-SNAPSHOT + + 4.0.0 + spdy-jetty + Jetty :: SPDY :: Jetty Binding + + + + maven-surefire-plugin + + true + + + + + + + + spdy-tests + - - maven-surefire-plugin - - - -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - - - + + maven-surefire-plugin + + + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar + + + - - - - - org.eclipse.jetty.spdy - spdy-core - ${project.version} - - - org.eclipse.jetty - jetty-server - ${project.version} - - - org.eclipse.jetty.npn - npn-api - ${project.version} - provided - - - junit - junit - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - test - - - - + + + + + + org.eclipse.jetty.spdy + spdy-core + ${project.version} + + + org.eclipse.jetty + jetty-server + ${project.version} + + + org.eclipse.jetty.npn + npn-api + ${project.version} + provided + + + junit + junit + + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + test + + + \ No newline at end of file From 0284e5e9d589464791fe4ce204cd2a881ccd12aa Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Mar 2012 14:16:36 -0600 Subject: [PATCH 4/6] make sure tests run with profile --- jetty-spdy/spdy-jetty-http/pom.xml | 1 + jetty-spdy/spdy-jetty/pom.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/jetty-spdy/spdy-jetty-http/pom.xml b/jetty-spdy/spdy-jetty-http/pom.xml index 704093b0beb..0bd2af8a969 100644 --- a/jetty-spdy/spdy-jetty-http/pom.xml +++ b/jetty-spdy/spdy-jetty-http/pom.xml @@ -28,6 +28,7 @@ maven-surefire-plugin + false -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar diff --git a/jetty-spdy/spdy-jetty/pom.xml b/jetty-spdy/spdy-jetty/pom.xml index 38281949232..7aec8f72263 100644 --- a/jetty-spdy/spdy-jetty/pom.xml +++ b/jetty-spdy/spdy-jetty/pom.xml @@ -28,6 +28,7 @@ maven-surefire-plugin + false -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar From 3134984bb2f67bb554e2e913ac7cfe26d44bedda Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Mar 2012 15:08:05 -0600 Subject: [PATCH 5/6] disabling spdy tests on release and commenting out jetty maven plugin usage --- jetty-spdy/spdy-jetty-http-webapp/pom.xml | 9 +++------ jetty-spdy/spdy-jetty-http/pom.xml | 10 +++------- jetty-spdy/spdy-jetty/pom.xml | 10 +++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/jetty-spdy/spdy-jetty-http-webapp/pom.xml b/jetty-spdy/spdy-jetty-http-webapp/pom.xml index 342d7e9a49b..5640d31716b 100644 --- a/jetty-spdy/spdy-jetty-http-webapp/pom.xml +++ b/jetty-spdy/spdy-jetty-http-webapp/pom.xml @@ -10,10 +10,8 @@ spdy-jetty-http-webapp war Jetty :: SPDY :: Jetty HTTP Web Application - - - - spdy-tests + + \ No newline at end of file diff --git a/jetty-spdy/spdy-jetty-http/pom.xml b/jetty-spdy/spdy-jetty-http/pom.xml index 0bd2af8a969..3a31efaa096 100644 --- a/jetty-spdy/spdy-jetty-http/pom.xml +++ b/jetty-spdy/spdy-jetty-http/pom.xml @@ -14,24 +14,20 @@ maven-surefire-plugin - true + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - - spdy-tests + eclipse-release maven-surefire-plugin - false - - -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - + true diff --git a/jetty-spdy/spdy-jetty/pom.xml b/jetty-spdy/spdy-jetty/pom.xml index 7aec8f72263..24ebf0b4359 100644 --- a/jetty-spdy/spdy-jetty/pom.xml +++ b/jetty-spdy/spdy-jetty/pom.xml @@ -14,24 +14,20 @@ maven-surefire-plugin - true + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - - spdy-tests + eclipse-release maven-surefire-plugin - false - - -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${project.version}/npn-boot-${project.version}.jar - + true From 3442e79b384171eebb4a88087e001a1b54ab7529 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Mar 2012 17:21:38 -0600 Subject: [PATCH 6/6] updated gzipfilter and user agent filter to take excluded paths, excluded path patterns, and excluded agent patterns. The latter two take regular expressions in order to match paths and user agents, thanks travis --- .../eclipse/jetty/servlets/GzipFilter.java | 118 ++++++++++++++++-- .../jetty/servlets/UserAgentFilter.java | 37 +++--- 2 files changed, 129 insertions(+), 26 deletions(-) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java index cf2a898ef54..1b993e6eedf 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java @@ -20,6 +20,7 @@ import java.io.UnsupportedEncodingException; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; +import java.util.regex.Pattern; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -67,12 +68,17 @@ public class GzipFilter extends UserAgentFilter protected Set _mimeTypes; protected int _bufferSize=8192; protected int _minGzipSize=256; - protected Set _excluded; + protected Set _excludedAgents; + protected Set _excludedAgentPatterns; + protected Set _excludedPaths; + protected Set _excludedPathPatterns; + /* ------------------------------------------------------------ */ /** * @see org.eclipse.jetty.servlets.UserAgentFilter#init(javax.servlet.FilterConfig) */ + @Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); @@ -93,21 +99,48 @@ public class GzipFilter extends UserAgentFilter while (tok.hasMoreTokens()) _mimeTypes.add(tok.nextToken()); } - tmp=filterConfig.getInitParameter("excludedAgents"); if (tmp!=null) { - _excluded=new HashSet(); + _excludedAgents=new HashSet(); StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _excluded.add(tok.nextToken()); + _excludedAgents.add(tok.nextToken()); } + + tmp=filterConfig.getInitParameter("excludeAgentPatterns"); + if (tmp!=null) + { + _excludedAgentPatterns=new HashSet(); + StringTokenizer tok = new StringTokenizer(tmp,",",false); + while (tok.hasMoreTokens()) + _excludedAgentPatterns.add(Pattern.compile(tok.nextToken())); + } + + tmp=filterConfig.getInitParameter("excludePaths"); + if (tmp!=null) + { + _excludedPaths=new HashSet(); + StringTokenizer tok = new StringTokenizer(tmp,",",false); + while (tok.hasMoreTokens()) + _excludedPaths.add(tok.nextToken()); + } + + tmp=filterConfig.getInitParameter("excludePathPatterns"); + if (tmp!=null) + { + _excludedPathPatterns=new HashSet(); + StringTokenizer tok = new StringTokenizer(tmp,",",false); + while (tok.hasMoreTokens()) + _excludedPathPatterns.add(Pattern.compile(tok.nextToken())); + } } /* ------------------------------------------------------------ */ /** * @see org.eclipse.jetty.servlets.UserAgentFilter#destroy() */ + @Override public void destroy() { } @@ -116,6 +149,7 @@ public class GzipFilter extends UserAgentFilter /** * @see org.eclipse.jetty.servlets.UserAgentFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */ + @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { @@ -126,14 +160,17 @@ public class GzipFilter extends UserAgentFilter if (ae != null && ae.indexOf("gzip")>=0 && !response.containsHeader("Content-Encoding") && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod())) { - if (_excluded!=null) + String ua = getUserAgent(request); + if (isExcludedAgent(ua)) { - String ua=getUserAgent(request); - if (_excluded.contains(ua)) - { - super.doFilter(request,response,chain); - return; - } + super.doFilter(request,response,chain); + return; + } + String requestURI = request.getRequestURI(); + if (isExcludedPath(requestURI)) + { + super.doFilter(request,response,chain); + return; } final GzipResponseWrapper wrappedResponse=newGzipResponseWrapper(request,response); @@ -181,7 +218,64 @@ public class GzipFilter extends UserAgentFilter super.doFilter(request,response,chain); } } - + + /** + * Checks to see if the UserAgent is excluded + * + * @param ua + * the user agent + * @return boolean true if excluded + */ + private boolean isExcludedAgent(String ua) + { + if (ua == null) + return false; + + if (_excludedAgents != null) + { + if (_excludedAgents.contains(ua)) + { + return true; + } + } + else if (_excludedAgentPatterns != null) + { + for (Pattern pattern : _excludedAgentPatterns) + { + if (pattern.matcher(ua).matches()) + { + return true; + } + } + } + + return false; + } + + /** + * Checks to see if the Path is excluded + * + * @param ua + * the request uri + * @return boolean true if excluded + */ + private boolean isExcludedPath(String requestURI) + { + if (requestURI == null) + return false; + if (_excludedPathPatterns != null) + { + for (Pattern pattern : _excludedPathPatterns) + { + if (pattern.matcher(requestURI).matches()) + { + return true; + } + } + } + return false; + } + /** * Allows derived implementations to replace ResponseWrapper implementation. * diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java index 78ef05ced14..71d60024c62 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java @@ -118,29 +118,38 @@ public class UserAgentFilter implements Filter String tag = (String)_agentCache.get(ua); - if (tag==null) + if (tag == null) { - Matcher matcher=_pattern.matcher(ua); - if (matcher.matches()) + if (_pattern != null) { - if(matcher.groupCount()>0) + Matcher matcher = _pattern.matcher(ua); + if (matcher.matches()) { - for (int g=1;g<=matcher.groupCount();g++) + if (matcher.groupCount() > 0) { - String group=matcher.group(g); - if (group!=null) - tag=tag==null?group:(tag+group); + for (int g = 1; g <= matcher.groupCount(); g++) + { + String group = matcher.group(g); + if (group != null) + tag = tag == null?group:(tag + group); + } + } + else + { + tag = matcher.group(); } } - else - tag=matcher.group(); } else - tag=ua; + { + tag = ua; + } - if (_agentCache.size()>=_agentCacheSize) - _agentCache.clear(); - _agentCache.put(ua,tag); + if (_agentCache.size() >= _agentCacheSize) + { + _agentCache.clear(); + } + _agentCache.put(ua,tag); } return tag;