Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Netty NIO HTTP Client",
"contributor": "olivergillespie",
"description": "Don't force Netty's unpooled ByteBuffer allocator when using the JDK SSL provider. The underlying Netty issue (netty/netty#9768) has been fixed in later versions."
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ protected SimpleChannelPoolAwareChannelPool newPool(URI key) {
ChannelPipelineInitializer pipelineInitializer = new ChannelPipelineInitializer(protocol,
protocolNegotiation,
sslContext,
sslProvider,
maxStreams,
initialWindowSize,
healthCheckPingPeriod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import static software.amazon.awssdk.utils.NumericUtils.saturatedCast;
import static software.amazon.awssdk.utils.StringUtils.lowerCase;

import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.pool.AbstractChannelPoolHandler;
import io.netty.channel.pool.ChannelPool;
Expand All @@ -44,7 +42,6 @@
import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.ssl.SslProvider;
import java.net.URI;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
Expand All @@ -64,7 +61,6 @@ public final class ChannelPipelineInitializer extends AbstractChannelPoolHandler
private final Protocol protocol;
private final ProtocolNegotiation protocolNegotiation;
private final SslContext sslCtx;
private final SslProvider sslProvider;
private final long clientMaxStreams;
private final int clientInitialWindowSize;
private final Duration healthCheckPingPeriod;
Expand All @@ -75,7 +71,6 @@ public final class ChannelPipelineInitializer extends AbstractChannelPoolHandler
public ChannelPipelineInitializer(Protocol protocol,
ProtocolNegotiation protocolNegotiation,
SslContext sslCtx,
SslProvider sslProvider,
long clientMaxStreams,
int clientInitialWindowSize,
Duration healthCheckPingPeriod,
Expand All @@ -85,7 +80,6 @@ public ChannelPipelineInitializer(Protocol protocol,
this.protocol = protocol;
this.protocolNegotiation = protocolNegotiation;
this.sslCtx = sslCtx;
this.sslProvider = sslProvider;
this.clientMaxStreams = clientMaxStreams;
this.clientInitialWindowSize = clientInitialWindowSize;
this.healthCheckPingPeriod = healthCheckPingPeriod;
Expand All @@ -108,12 +102,6 @@ public void channelCreated(Channel ch) {

pipeline.addLast(sslHandler);
pipeline.addLast(SslCloseCompletionEventHandler.getInstance());

// Use unpooled allocator to avoid increased heap memory usage from Netty 4.1.43.
// See https://github.com/netty/netty/issues/9768
if (sslProvider == SslProvider.JDK) {
ch.config().setOption(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT);
}
}

configureProtocolHandlers(ch, pipeline, protocol, sslCtxPresent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@

package software.amazon.awssdk.http.nio.netty.internal;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static software.amazon.awssdk.http.SdkHttpConfigurationOption.GLOBAL_HTTP_DEFAULTS;

import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.pool.ChannelPool;
import io.netty.handler.codec.http2.Http2MultiplexHandler;
Expand All @@ -50,15 +46,6 @@ public class ChannelPipelineInitializerTest {
private final URI TARGET_URI = URI.create("https://some-awesome-service-1234.amazonaws.com:8080");
private static final SslProvider SSL_PROVIDER = SslProvider.JDK;

@Test
public void channelConfigOptionCheck() {
ChannelPipelineInitializer pipelineInitializer = createChannelPipelineInitializer(Protocol.HTTP1_1, ProtocolNegotiation.ASSUME_PROTOCOL);
Channel channel = new EmbeddedChannel();
pipelineInitializer.channelCreated(channel);

assertThat(channel.config().getOption(ChannelOption.ALLOCATOR), is(UnpooledByteBufAllocator.DEFAULT));
}

@Test
@EnabledIf("alpnSupported")
public void h2AlpnEnabled_shouldUseAlpn() {
Expand Down Expand Up @@ -126,7 +113,6 @@ private ChannelPipelineInitializer createChannelPipelineInitializer(Protocol pro
return new ChannelPipelineInitializer(protocol,
protocolNegotiation,
sslContextProvider.sslContext(),
SSL_PROVIDER,
100,
1024,
Duration.ZERO,
Expand Down