Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ public String host() {

@Override
public int port() {
return httpServerExchange.getHostPort();
try {
return httpServerExchange.getHostPort();

Copy link
Copy Markdown
Contributor Author

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.

} 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Guard the later peer port lookup

The original request still causes a null pointer exception and stops later request decoration.

Assertion details
  • Input: A request has no usable Host port, uses a scheme other than HTTP or HTTPS, and has a null destination address.
  • Expected: The decorator must omit the unavailable port and continue without an exception.
  • Actual: port() returns 0. onRequest() then calls peerPort(), which calls getPort() on the null destination address outside the URL catch.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest · Open Bits AI session

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
Expand Down
Loading