Commit 1c1d666
authored
Handle path parsing for opaque URIs (#2067)
When we're working with an opaque URI that the netty code can't parse a
path from, we can end up with a null path, causing a NPE as we try to
parse it.
This adds a quick check — if we don't have a path, just return the URI.
This matches the existing behavior — scope out the
`parseUriFromNetty_unknown` test:
```
@test
void parseUriFromNetty_unknown() {
EmbeddedChannel channel = new EmbeddedChannel(new ClientRequestReceiver(null));
channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
HttpRequestMessageImpl result;
{
channel.writeInbound(
new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "asdf", Unpooled.buffer()));
result = channel.readInbound();
result.disposeBufferedBody();
}
assertThat(result.getPath()).isEqualTo("asdf");
channel.close();
}
```
We can match this behavior with our null check defense.1 parent 59abacd commit 1c1d666
2 files changed
Lines changed: 21 additions & 1 deletion
File tree
- zuul-core/src
- main/java/com/netflix/zuul/netty/server
- test/java/com/netflix/zuul/netty/server
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
424 | 428 | | |
425 | 429 | | |
426 | 430 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
539 | 555 | | |
540 | 556 | | |
541 | 557 | | |
| |||
0 commit comments