-
Notifications
You must be signed in to change notification settings - Fork 869
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
Skip ALPN if request is HTTP endpoint #5854
base: master
Are you sure you want to change the base?
Conversation
...-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/NettyNioAsyncHttpClient.java
Outdated
Show resolved
Hide resolved
@@ -99,7 +99,9 @@ public void channelCreated(Channel ch) { | |||
ch.attr(CHANNEL_DIAGNOSTICS).set(new ChannelDiagnostics(ch)); | |||
ch.attr(PROTOCOL_FUTURE).set(new CompletableFuture<>()); | |||
ChannelPipeline pipeline = ch.pipeline(); | |||
if (sslCtx != null) { | |||
|
|||
boolean sslCtxPresent = sslCtx != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the reason for this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are saving the boolean as variable since we pass to configureProtocolHandlers()
to fallback to prior knowledge if sslCtx is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have test cases for this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is existing behavior, to use prior knowledge. Covered by test here, to make sure we don't throw UnsupportedOperationException
Line 49 in ed58871
assertThat(e.getMessage()).doesNotContain("ALPN can only be used with HTTPS, not HTTP"); |
throw new UnsupportedOperationException("ALPN can only be used with HTTPS, not HTTP."); | ||
} | ||
if (protocolNegotiation == ProtocolNegotiation.ALPN) { | ||
log.debug(null, () -> "Default client protocol negotiation is ALPN, but request endpoint is HTTP. Prior " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log will be logged for every request. What is the significance of this log, as in if the default ALPN is not supported for the service, won't we immediately get server-side exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline, will remove logging. We fallback to prior knowledge in ChannelPipelineInitializer
. This scenario of ALPN default setting with HTTP endpoint should only be present in mock tests
@@ -99,7 +99,9 @@ public void channelCreated(Channel ch) { | |||
ch.attr(CHANNEL_DIAGNOSTICS).set(new ChannelDiagnostics(ch)); | |||
ch.attr(PROTOCOL_FUTURE).set(new CompletableFuture<>()); | |||
ChannelPipeline pipeline = ch.pipeline(); | |||
if (sslCtx != null) { | |||
|
|||
boolean sslCtxPresent = sslCtx != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have test cases for this change ?
Can we please add change logs . |
Quality Gate passedIssues Measures |
Motivation and Context
Mock tests with h2 clients making requests to HTTP endpoints fail with recent ALPN addition
Modifications
Skip adding ALPN handler if request endpoint is HTTP and the default client setting is ALPN. This maintains previous behavior of prior knowledge protocol negotiation, and avoids breaking changes for existing generated clients with h2 protocol setting
Continue to throw error if request endpoint is HTTP and user configures ALPN on client
Testing
Added unit tests
Screenshots (if appropriate)
Types of changes