Skip to content
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

Add remote address information in SessionProtocolNegotiationException #6113

Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ private void connect(SessionProtocol desiredProtocol, SerializationFormat serial
notifyConnect(desiredProtocol, key,
eventLoop.newFailedFuture(
new SessionProtocolNegotiationException(
desiredProtocol, "previously failed negotiation")),
desiredProtocol,
"previously failed negotiation (remoteAddress: " +
remoteAddress + ")")),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
remoteAddress + ")")),
remoteAddress + ')')),

promise, timingsBuilder);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ void finishWithNegotiationFailure(
final ChannelPipeline pipeline = ctx.pipeline();
pipeline.channel().eventLoop().execute(
() -> pipeline.fireUserEventTriggered(
new SessionProtocolNegotiationException(expected, actual, reason)));
new SessionProtocolNegotiationException(
expected, actual, reason + " (channel: " + pipeline.channel() + ")")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expected, actual, reason + " (channel: " + pipeline.channel() + ")")));
expected, actual, reason + " (channel: " + pipeline.channel() + ')')));

ctx.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void scheduleSessionTimeout(Channel channel, Promise<Channel> sessionPro
sessionTimeoutFuture = channel.eventLoop().schedule(() -> {
if (sessionPromise.tryFailure(new SessionProtocolNegotiationException(
desiredProtocol,
"connection established, but session creation timed out: " + channel))) {
"connection established, but session creation timed out. (channel: " + channel + ")"))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"connection established, but session creation timed out. (channel: " + channel + ")"))) {
"connection established, but session creation timed out. (channel: " + channel + ')'))) {

channel.close();
}
}, connectionTimeoutMillis, TimeUnit.MILLISECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ void shouldRejectH2WithoutAlpn() {
assertThatThrownBy(() -> client.get("/"))
.isInstanceOf(UnprocessedRequestException.class)
.hasCauseInstanceOf(SessionProtocolNegotiationException.class)
.hasMessageContaining("expected: h2, actual: h1, " +
"reason: unexpected protocol negotiation result");
.hasMessageContainingAll(
"expected: h2",
"actual: h1",
"reason: unexpected protocol negotiation result",
"R:127.0.0.1"
);
}
}
}
Loading