-
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
NullPointerException with default servlet, include and welcome pages #9966
Labels
Bug
For general bugs on Jetty side
Comments
I think that the default servlet should do: if (contextResponse != null)
{
String characterEncoding = contextResponse.getRawCharacterEncoding();
if (characterEncoding != null)
content = new ForcedCharacterEncodingHttpContent(content, characterEncoding);
} only after ensuring that the content is not a directory (or do some other verification). |
lorban
added a commit
that referenced
this issue
Jun 26, 2023
#9966 adapt character encoding when including a path that is a directory listing Signed-off-by: Ludovic Orban <[email protected]>
@grgrzybek I've pushed a fix (see #9970) to the jetty-12.0.x branch. If you've got any feedback, I'd be happy to hear it. Thanks! |
Works perfectly - thanks @lorban ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jetty version(s)
12.0.0 SNAPSHOT
Description
How to reproduce?
I added a comment under #9927, but here's separate issue.
@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
/gateway/x?what=include&where=/
:org.eclipse.jetty.ee10.servlet.ServletApiResponse#getWriter()
calls:org.eclipse.jetty.ee10.servlet.ServletContextResponse#getCharacterEncoding(boolean)
calls:so
org.eclipse.jetty.ee10.servlet.ServletContextResponse#_characterEncoding
is set toiso-8859-1
.Because the forward is for
/
, default servlet is involved (because I need to test welcome files).org.eclipse.jetty.ee10.servlet.DefaultServlet#doGet()
has this fragment:and the constructor is:
the
content
is:the underlying resource is directory, so the extension is
*
and the resulting content type is null.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
The text was updated successfully, but these errors were encountered: