From 1eec23433632b6de47077bf78076cfb754e65148 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 3 Apr 2018 21:22:16 +1000 Subject: [PATCH] Minor changes after review by gregw. Signed-off-by: Lachlan Roberts --- .../src/main/java/org/eclipse/jetty/http/HttpCompliance.java | 4 +++- .../java/org/eclipse/jetty/server/HttpChannelOverHttp.java | 4 +--- .../org/eclipse/jetty/server/MultiPartCleanerListener.java | 2 +- .../src/main/java/org/eclipse/jetty/server/Request.java | 5 +++-- .../src/test/java/org/eclipse/jetty/server/RequestTest.java | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpCompliance.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpCompliance.java index c51bc0f32eb..9e7022b35e4 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpCompliance.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpCompliance.java @@ -49,7 +49,7 @@ import org.eclipse.jetty.util.log.Logger; * be altered in code and will affect all usages of the mode. */ public enum HttpCompliance // TODO in Jetty-10 convert this enum to a class so that extra custom modes can be defined dynamically -{ +{ /** A Legacy compliance mode to match jetty's behavior prior to RFC2616 and RFC7230. It only * contains {@link HttpComplianceSection#METHOD_CASE_SENSITIVE} */ @@ -82,6 +82,8 @@ public enum HttpCompliance // TODO in Jetty-10 convert this enum to a class so t @Deprecated CUSTOM3(sectionsByProperty("CUSTOM3")); + public static final String VIOLATIONS_ATTR = "org.eclipse.jetty.http.compliance.violations"; + private static final Logger LOG = Log.getLogger(HttpParser.class); private static EnumSet sectionsByProperty(String property) { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelOverHttp.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelOverHttp.java index c2fbf69bdd8..3e2f0cbd654 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelOverHttp.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelOverHttp.java @@ -51,8 +51,6 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque { private static final Logger LOG = Log.getLogger(HttpChannelOverHttp.class); private final static HttpField PREAMBLE_UPGRADE_H2C = new HttpField(HttpHeader.UPGRADE, "h2c"); - public static final String ATTR_COMPLIANCE_VIOLATIONS = "org.eclipse.jetty.http.compliance.violations"; - private final HttpFields _fields = new HttpFields(); private final MetaData.Request _metadata = new MetaData.Request(_fields); private final HttpConnection _httpConnection; @@ -291,7 +289,7 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque { if (_complianceViolations != null && !_complianceViolations.isEmpty()) { - this.getRequest().setAttribute(ATTR_COMPLIANCE_VIOLATIONS, _complianceViolations); + this.getRequest().setAttribute(HttpCompliance.VIOLATIONS_ATTR, _complianceViolations); _complianceViolations=null; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartCleanerListener.java b/jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartCleanerListener.java index af7310c706c..40ae2cb04e8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartCleanerListener.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartCleanerListener.java @@ -50,7 +50,7 @@ public class MultiPartCleanerListener implements ServletRequestListener { parts.close(); } - catch (Exception e) + catch (Throwable e) { sre.getServletContext().log("Errors deleting multipart tmp files", e); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 2904ba684a6..7eb705f2a0d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -66,6 +66,7 @@ import javax.servlet.http.Part; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HostPortHttpField; +import org.eclipse.jetty.http.HttpCompliance; import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; @@ -2605,11 +2606,11 @@ public class Request implements HttpServletRequest if (!nonComplianceWarnings.isEmpty()) { @SuppressWarnings("unchecked") - List violations = (List)getAttribute(HttpChannelOverHttp.ATTR_COMPLIANCE_VIOLATIONS); + List violations = (List)getAttribute(HttpCompliance.VIOLATIONS_ATTR); if (violations==null) { violations = new ArrayList<>(); - setAttribute(HttpChannelOverHttp.ATTR_COMPLIANCE_VIOLATIONS,violations); + setAttribute(HttpCompliance.VIOLATIONS_ATTR,violations); } for(NonCompliance nc : nonComplianceWarnings) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java index 5de3d7d67d5..2d6c06f4763 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java @@ -59,6 +59,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; import org.eclipse.jetty.http.BadMessageException; +import org.eclipse.jetty.http.HttpCompliance; import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.server.LocalConnector.LocalEndPoint; @@ -1818,7 +1819,7 @@ public class RequestTest assertNotNull(foo); assertTrue(foo.getSize() > 0); response.setStatus(200); - List violations = (List)request.getAttribute(HttpChannelOverHttp.ATTR_COMPLIANCE_VIOLATIONS); + List violations = (List)request.getAttribute(HttpCompliance.VIOLATIONS_ATTR); if(violations != null) { for(String v : violations)