Commit c31f989
Guard Undertow port() against internal NPE (quick fix) (DataDog#12373)
Guard Undertow port() against internal NPE
HttpServerExchange.getHostPort() can NPE inside Undertow itself when
there's no Host header, the scheme isn't http/https, and the
connection's local address isn't an InetSocketAddress (e.g. AJP or a
Unix domain socket transport). Fall back to 0 (the existing "no port"
sentinel used throughout URIUtils) rather than letting the NPE
propagate into the instrumented application.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Guard UndertowDecorator.peerPort() against the same null destination-address NPE
The port() fix in HttpServerExchangeURIDataAdapter only covers the Host-port
lookup; HttpServerDecorator.onRequest() also calls peerPort(), which reads
exchange.getDestinationAddress().getPort() directly outside any try/catch, so
the same null-destination-address condition (AJP, Unix domain socket
transport, wrapped/detached ServerConnection) still NPEs one call site later.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Merge branch 'master' into dougqh/fix-undertow-port-npe
Merge branch 'master' into dougqh/fix-undertow-port-npe
Suppress SpotBugs DCN_NULLPOINTER_EXCEPTION for Undertow port() NPE guard
Undertow's getHostPort() NPEs internally in some transports (AJP, unix
domain sockets) rather than on a null we could check beforehand, so the
catch is intentional and can't be replaced with a null-check.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Guard HttpServerExchangeURIDataAdapter.host() against the same NPE as port()
Undertow's getHostName() falls back to getDestinationAddress().getHostString()
when there's no Host header, which NPEs the same way getHostPort() does when
the destination address is null (AJP, Unix domain socket, or wrapped
connections). Found by jordan-wong via a live error-tracking hit on this
exact file/line.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Merge branch 'master' into dougqh/fix-undertow-port-npe
Co-authored-by: devflow.devflow-routing-intake <[email protected]>1 parent a41bd4c commit c31f989
2 files changed
Lines changed: 29 additions & 3 deletions
File tree
- dd-java-agent/instrumentation/undertow/undertow-common/src/main/java/datadog/trace/instrumentation/undertow
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
21 | 32 | | |
22 | 33 | | |
23 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
24 | 41 | | |
25 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
26 | 47 | | |
27 | 48 | | |
28 | 49 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
0 commit comments