-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetty 12 inserted handler in ee10 servlet context #9927
Conversation
…n't backed by a Path Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: gregw <[email protected]>
This reverts part of commit 12b7e7b
@gregw can you edit the initial post to include a sentence or two on the motivation for the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a trivial javadoc error. However, it should be fixed. Also, for a more thorough review, I think we need a hangout.
jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1st review pass
...c/main/java/org/eclipse/jetty/websocket/core/server/internal/WebSocketHttpFieldsWrapper.java
Outdated
Show resolved
Hide resolved
...0/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextRequest.java
Outdated
Show resolved
Hide resolved
.../jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java
Outdated
Show resolved
Hide resolved
...y-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/AsyncServletTest.java
Outdated
Show resolved
Hide resolved
...etty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/AsyncServletLongPollTest.java
Outdated
Show resolved
Hide resolved
.../jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java
Outdated
Show resolved
Hide resolved
...10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/add-jetty-test-webapp.xml
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/jetty/websocket/core/server/internal/WebSocketHttpFieldsWrapper.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/jetty/websocket/core/server/internal/WebSocketHttpFieldsWrapper.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
Show resolved
Hide resolved
@janbartel @lorban @lachlan-roberts I've now added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides a few nits.
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerTest.java
Outdated
Show resolved
Hide resolved
...e10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletRequestState.java
Outdated
Show resolved
Hide resolved
# Conflicts: # jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletChannel.java # jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/AsyncServletTest.java
@janbartel @lorban @lachlan-roberts I think the test failure is a flake. So can I get a review on this before tonight's meeting? |
…-late-servlet-wrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of an oddity with the ServletRequestInfo.getServletContextRequest()
method, but other than that, +1.
...0/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextRequest.java
Outdated
Show resolved
Hide resolved
removed explicit method to navigate from Request/Response Info back to core context request/response
21da275
@janbartel @lachlan-roberts @lorban sorry, but after that last little tweak, I need a review from at least 1 of you again |
@gregw I can't track the exact part of 0b1c28a, but I think it started causing NPE in some special case. My servlet is invoked with String what = req.getParameter("what");
String where = req.getParameter("where");
switch (what) {
case "redirect":
resp.sendRedirect(where);
return;
case "forward":
// we can't send anything when forwarding
req.getRequestDispatcher(where).forward(req, resp);
return;
case "include":
resp.getWriter().print(">>>");
req.getRequestDispatcher(where).include(req, resp);
resp.getWriter().print("<<<");
return;
default:
}
String encoding = getServletResponseInfo().getCharacterEncoding(true);
if (setContentType)
setCharacterEncoding(encoding, EncodingFrom.DEFAULT); so
if (contextResponse != null)
{
String characterEncoding = contextResponse.getRawCharacterEncoding();
if (characterEncoding != null)
content = new ForcedCharacterEncodingHttpContent(content, characterEncoding);
} and the constructor is: public ForcedCharacterEncodingHttpContent(HttpContent content, String characterEncoding)
{
super(content);
this.characterEncoding = characterEncoding;
String mimeType = content.getContentTypeValue();
int idx = mimeType.indexOf(";charset");
if (idx >= 0)
mimeType = mimeType.substring(0, idx);
this.contentType = mimeType + ";charset=" + this.characterEncoding;
} the
the underlying resource is directory, so the extension is so I'm getting NullPointerException. My test you can run (without bothering with OSGi stuff) is https://github.com/ops4j/org.ops4j.pax.web/blob/1b26a2f8ea394d696a6780ff0fa92b2613019dff/pax-web-jetty/src/test/java/org/ops4j/pax/web/service/jetty/internal/UnifiedJettyTest.java#L361 |
This PR refactors the ee10 handing of servlet API request and response objects:
ServletContextHandler
matches the request to a servlet and creates a one time onlyServletContextRequest
and aServletContextResponse
ServletChannel
object with all the heavy weightHttpInput
andHttpOutput
object is associated with theServletContextRequest
andServletContextResponse
.ServletHandler
, the possibly wrapped request, response and callback are associated with theServletChannel
before handling.ServletApiRequest
andServletApiResponse
use the possibly wrapped request/responseI have added tests to check that GzipHandler can now be nested inside of an EE10 context.