Skip to content

Handle path parsing for opaque URIs#2067

Merged
AlexanderEllis merged 1 commit intomasterfrom
alex/path-parsing
Feb 5, 2026
Merged

Handle path parsing for opaque URIs#2067
AlexanderEllis merged 1 commit intomasterfrom
alex/path-parsing

Conversation

@AlexanderEllis
Copy link
Contributor

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.

@AlexanderEllis AlexanderEllis merged commit 1c1d666 into master Feb 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants