Skip to content
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

ServletUriComponentsBuilder#initFromRequest can cause NPE [SPR-12723] #17320

spring-issuemaster opened this issue Feb 17, 2015 · 0 comments


None yet
2 participants
Copy link

commented Feb 17, 2015

Seth Katzman opened SPR-12723 and commented

When using ServletUriComponentsBuilder.fromCurrentServletMapping() in a test environment (and probably some others), a NullPointerException can occur in method initFromRequest(HttpServletRequest request) on line 147.

Specifically, if the HTTP servlet request returns a null scheme value, a NullPointerException can occur on the following line...

if (scheme.equals("http") && port != 80 || scheme.equals("https") && port != 443) {

The variable names is being compared for equality to the constant string which leads to an NPE. This should either be reversed ("http".equals(scheme) / "https".equals(scheme)) or preconditions should check for this scenario earlier in the code branching.

The partial stack trace as follows:

at c.b.c.r.a.R.g(

Affects: 3.2.13, 4.1.4

Referenced from: commits 61cc3b5, 3ed24bc, 2a240b0

Backported to: 3.2.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.