-
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
NPE in AllowedResourceAliasChecker.getPath() #7059
Comments
It's always a good idea to define a Base Resource. Having no Base Resource will break many APIs. Not just this I know that if you, or any of your libraries, call things like ... ServletContext.getRealPath(String) Those APIs will break as well. If you use Servlet Auth (authentication or authorization) the constraint mapping will even fail. |
@tivervac this exception is caught in What exactly do you see to be the issue here, is it just that you think this should be logged at a higher level like debug or warn with a more descriptive message? |
@lachlan-roberts I saw it by running my application as debug with an NPE breakpoint on. My issue is that if you look at the code, it's very obvious IMO it would be better to handle this case specifically, checking for null before dereferencing the possibly null resource instead of just catching the NPE. Logging at a higher level with something like |
@tivervac I agree, I'll put up a PR for this. I don't think a null base resource should produce a warning here as it is a valid configuration. I think it should just set some flag to completely disable the |
…doStart Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…Checkers Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…doStart Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…ve been added. Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…doStart (#7076) - prevent an internal NPE in AllowedResourceAliasChecker doStart - Fix LifeCycle issues with AllowedResourceAliasChecker - add null check for protected targets in toString. - improve warning message for AllowedResourceAliasChecker - add AllowedResourceAliasCheckerTest
…doStart (9.4) (#7081) - prevent an internal NPE in AllowedResourceAliasChecker doStart - use LifeCycle listener instead of EventListener - Improve warning log for AllowedResourceAliasChecker
Jetty version(s)
10.0.7
Java version/vendor
(use: java -version)
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment 18.9 (build 11.0.13+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8, mixed mode, sharing)
OS type/version
Fedora 34; kernel 5.14.13-200.fc34.x86_64
Description
How to reproduce?
Create a server with a
ServletContextHandler
without abaseResource
(not sure if this minimal config is enough, but the important part is I don't configure a base resource for my ServletContextHandler).When you then start the server you'll hit the following function
org.eclipse.jetty.server.AllowedResourceAliasChecker.getPath(Resource)
This one tries to get the path of the contextHandler's base resource, which is null
resource.getFile().toPath()
. Since it's null the following line will throw an NPE.It will be caught by the very generic catch block underneath, but I'm sure that a better error message can be thought of.
The text was updated successfully, but these errors were encountered: