-
Notifications
You must be signed in to change notification settings - Fork 355
Guard Undertow port() against internal NPE #12373
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,13 @@ public String host() { | |
|
|
||
| @Override | ||
| public int port() { | ||
| return httpServerExchange.getHostPort(); | ||
| try { | ||
| return httpServerExchange.getHostPort(); | ||
| } catch (final NullPointerException e) { | ||
| // Undertow's getHostPort() can NPE internally (e.g. no Host header and a connection whose | ||
| // local address isn't an InetSocketAddress, such as AJP or a Unix domain socket transport). | ||
| return 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The original request still causes a null pointer exception and stops later request decoration. Assertion details
Was this helpful? React 👍 or 👎
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense.. we should probably instead pass some indication to skip the unavailable port or pass the error on elsewhere? |
||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
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.
I'm debating how best to add a test.
It could be done via a mock, but in my mind, that does prove much.
To create the problem for real, requires a rather specific undertow set-up, but maybe I (Claude) can figure out how to reconstruct that scenario.