From b3739f42b85fc1870ef520625185ebee591a61ef Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Sun, 30 Sep 2018 07:01:06 -0500 Subject: [PATCH 1/4] Issue #2936 - Improving testcase to replicate reported scenario as described --- .../eclipse/jetty/servlet/ErrorPageTest.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java index 5ca8913035c..b611afb6f6f 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java @@ -65,12 +65,15 @@ public class ErrorPageTest context.addServlet(FailClosedServlet.class, "/fail-closed/*"); context.addServlet(ErrorServlet.class, "/error/*"); context.addServlet(AppServlet.class, "/app/*"); + context.addServlet(LongerAppServlet.class, "/longer.app/*"); ErrorPageErrorHandler error = new ErrorPageErrorHandler(); context.setErrorHandler(error); error.addErrorPage(599,"/error/599"); + error.addErrorPage(400,"/error/400"); + // error.addErrorPage(500,"/error/500"); error.addErrorPage(IllegalStateException.class.getCanonicalName(),"/error/TestException"); - error.addErrorPage(BadMessageException.class,"/error/TestException"); + error.addErrorPage(BadMessageException.class,"/error/BadMessageException"); error.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,"/error/GlobalErrorPage"); _server.start(); @@ -164,8 +167,8 @@ public class ErrorPageTest public void testBadMessage() throws Exception { String response = _connector.getResponse("GET /app?baa=%88%A4 HTTP/1.0\r\n\r\n"); - assertThat(response, Matchers.containsString("HTTP/1.1 400 Unable to parse URI query")); - assertThat(response, Matchers.containsString("ERROR_PAGE: /TestException")); + assertThat(response, Matchers.containsString("HTTP/1.1 400 Bad Request")); + assertThat(response, Matchers.containsString("ERROR_PAGE: /BadMessageException")); assertThat(response, Matchers.containsString("ERROR_MESSAGE: Unable to parse URI query")); assertThat(response, Matchers.containsString("ERROR_CODE: 400")); assertThat(response, Matchers.containsString("ERROR_EXCEPTION: org.eclipse.jetty.http.BadMessageException: 400: Unable to parse URI query")); @@ -177,13 +180,21 @@ public class ErrorPageTest public static class AppServlet extends HttpServlet implements Servlet + { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + request.getRequestDispatcher("/longer.app/").forward(request, response); + } + } + + public static class LongerAppServlet extends HttpServlet implements Servlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); writer.println(request.getRequestURI()); - writer.println(request.getParameterMap().toString()); } } From fe66e3d0cbda56c05c5e9de2cb7b59cd199c7096 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 1 Oct 2018 10:43:57 -0500 Subject: [PATCH 2/4] Issue #2936 - Allow Dispatcher.error() to work for BadMessageException Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/server/Dispatcher.java | 21 +++++++++++++++++-- .../eclipse/jetty/servlet/ErrorPageTest.java | 6 +++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java index bba38c90b6e..d2033a488b7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java @@ -31,6 +31,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.Attributes; @@ -195,8 +196,24 @@ public class Dispatcher implements RequestDispatcher baseRequest.setContextPath(_contextHandler.getContextPath()); baseRequest.setServletPath(null); baseRequest.setPathInfo(_pathInContext); - if (_uri.getQuery()!=null || old_uri.getQuery()!=null) - baseRequest.mergeQueryParameters(old_uri.getQuery(),_uri.getQuery(), true); + + if (_uri.getQuery() != null || old_uri.getQuery() != null) + { + try + { + baseRequest.mergeQueryParameters(old_uri.getQuery(), _uri.getQuery(), true); + } + catch (BadMessageException e) + { + // Only throw BME if not in Error Dispatch Mode + // This allows application ErrorPageErrorHandler to handle BME messages + Boolean inErrorDispatch = (Boolean) request.getAttribute(__ERROR_DISPATCH); + if(inErrorDispatch == null || !inErrorDispatch) + { + throw e; + } + } + } baseRequest.setAttributes(attr); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java index b611afb6f6f..7fd8431a4cb 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java @@ -167,11 +167,11 @@ public class ErrorPageTest public void testBadMessage() throws Exception { String response = _connector.getResponse("GET /app?baa=%88%A4 HTTP/1.0\r\n\r\n"); - assertThat(response, Matchers.containsString("HTTP/1.1 400 Bad Request")); + assertThat(response, Matchers.containsString("HTTP/1.1 400 Bad query encoding")); assertThat(response, Matchers.containsString("ERROR_PAGE: /BadMessageException")); - assertThat(response, Matchers.containsString("ERROR_MESSAGE: Unable to parse URI query")); + assertThat(response, Matchers.containsString("ERROR_MESSAGE: Bad query encoding")); assertThat(response, Matchers.containsString("ERROR_CODE: 400")); - assertThat(response, Matchers.containsString("ERROR_EXCEPTION: org.eclipse.jetty.http.BadMessageException: 400: Unable to parse URI query")); + assertThat(response, Matchers.containsString("ERROR_EXCEPTION: org.eclipse.jetty.http.BadMessageException: 400: Bad query encoding")); assertThat(response, Matchers.containsString("ERROR_EXCEPTION_TYPE: class org.eclipse.jetty.http.BadMessageException")); assertThat(response, Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$AppServlet-")); assertThat(response, Matchers.containsString("ERROR_REQUEST_URI: /app")); From 57ef060325ba094b2d44264d1c0e2f24918d50b7 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 2 Oct 2018 08:39:05 -0500 Subject: [PATCH 3/4] Issue #2936 - Allow Dispatcher.error() to work for BadMessageException + Applying fixes from review Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/server/Dispatcher.java | 11 +++++++-- .../eclipse/jetty/servlet/ErrorPageTest.java | 24 ++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java index d2033a488b7..c1baef1553d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java @@ -36,9 +36,13 @@ import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.Attributes; import org.eclipse.jetty.util.MultiMap; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; public class Dispatcher implements RequestDispatcher { + private static final Logger LOG = Log.getLogger(Dispatcher.class); + public final static String __ERROR_DISPATCH="org.eclipse.jetty.server.Dispatcher.ERROR"; /** Dispatch include attribute names */ @@ -207,11 +211,14 @@ public class Dispatcher implements RequestDispatcher { // Only throw BME if not in Error Dispatch Mode // This allows application ErrorPageErrorHandler to handle BME messages - Boolean inErrorDispatch = (Boolean) request.getAttribute(__ERROR_DISPATCH); - if(inErrorDispatch == null || !inErrorDispatch) + if (dispatch != DispatcherType.ERROR) { throw e; } + else + { + LOG.warn("Ignoring Original Bad Request Query String: " + old_uri, e); + } } } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java index 7fd8431a4cb..a0c230d5fec 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java @@ -92,7 +92,6 @@ public class ErrorPageTest public void testSendErrorClosedResponse() throws Exception { String response = _connector.getResponse("GET /fail-closed/ HTTP/1.0\r\n\r\n"); - System.out.println(response); assertThat(response,Matchers.containsString("HTTP/1.1 599 599")); assertThat(response,Matchers.containsString("DISPATCH: ERROR")); assertThat(response,Matchers.containsString("ERROR_PAGE: /599")); @@ -166,16 +165,19 @@ public class ErrorPageTest @Test public void testBadMessage() throws Exception { - String response = _connector.getResponse("GET /app?baa=%88%A4 HTTP/1.0\r\n\r\n"); - assertThat(response, Matchers.containsString("HTTP/1.1 400 Bad query encoding")); - assertThat(response, Matchers.containsString("ERROR_PAGE: /BadMessageException")); - assertThat(response, Matchers.containsString("ERROR_MESSAGE: Bad query encoding")); - assertThat(response, Matchers.containsString("ERROR_CODE: 400")); - assertThat(response, Matchers.containsString("ERROR_EXCEPTION: org.eclipse.jetty.http.BadMessageException: 400: Bad query encoding")); - assertThat(response, Matchers.containsString("ERROR_EXCEPTION_TYPE: class org.eclipse.jetty.http.BadMessageException")); - assertThat(response, Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$AppServlet-")); - assertThat(response, Matchers.containsString("ERROR_REQUEST_URI: /app")); - assertThat(response, Matchers.containsString("getParameterMap()= {}")); + try (StacklessLogging ignore = new StacklessLogging(Dispatcher.class)) + { + String response = _connector.getResponse("GET /app?baa=%88%A4 HTTP/1.0\r\n\r\n"); + assertThat(response, Matchers.containsString("HTTP/1.1 400 Bad query encoding")); + assertThat(response, Matchers.containsString("ERROR_PAGE: /BadMessageException")); + assertThat(response, Matchers.containsString("ERROR_MESSAGE: Bad query encoding")); + assertThat(response, Matchers.containsString("ERROR_CODE: 400")); + assertThat(response, Matchers.containsString("ERROR_EXCEPTION: org.eclipse.jetty.http.BadMessageException: 400: Bad query encoding")); + assertThat(response, Matchers.containsString("ERROR_EXCEPTION_TYPE: class org.eclipse.jetty.http.BadMessageException")); + assertThat(response, Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$AppServlet-")); + assertThat(response, Matchers.containsString("ERROR_REQUEST_URI: /app")); + assertThat(response, Matchers.containsString("getParameterMap()= {}")); + } } From baca9cae3982a51a39c406f9f3a457caa4fbf700 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 3 Oct 2018 09:54:05 +1000 Subject: [PATCH 4/4] Use cache to download to mongo and upgrade mongodb plugin (#2949) * cache downloading mongodb and upgrade mongodb embeded plugin Signed-off-by: olivier lamy * force mongodb version Signed-off-by: olivier lamy --- tests/test-sessions/test-mongodb-sessions/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test-sessions/test-mongodb-sessions/pom.xml b/tests/test-sessions/test-mongodb-sessions/pom.xml index c1f719beadc..bc6224e3b78 100644 --- a/tests/test-sessions/test-mongodb-sessions/pom.xml +++ b/tests/test-sessions/test-mongodb-sessions/pom.xml @@ -121,7 +121,7 @@ com.github.joelittlejohn.embedmongo embedmongo-maven-plugin - 0.3.5 + 0.4.1 @@ -137,6 +137,8 @@ false + https://jenkins.webtide.net/userContent/ + 2.2.1