Skip to content

Commit 48c03ba

Browse files
authored
Update Netty 4.1.115.Final metadata (#618)
- Update Netty 4.1.115.Final metadata - Add junit test
1 parent 07da6a7 commit 48c03ba

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

metadata/io.netty/netty-common/4.1.115.Final/reflect-config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,6 +3379,28 @@
33793379
}
33803380
]
33813381
},
3382+
{
3383+
"condition": {
3384+
"typeReachable": "io.netty.util.internal.shaded.org.jctools.queues.MpmcArrayQueueConsumerIndexField"
3385+
},
3386+
"name": "io.netty.util.internal.shaded.org.jctools.queues.MpmcArrayQueueConsumerIndexField",
3387+
"fields": [
3388+
{
3389+
"name": "consumerIndex"
3390+
}
3391+
]
3392+
},
3393+
{
3394+
"condition": {
3395+
"typeReachable": "io.netty.util.internal.shaded.org.jctools.queues.MpmcArrayQueueProducerIndexField"
3396+
},
3397+
"name": "io.netty.util.internal.shaded.org.jctools.queues.MpmcArrayQueueProducerIndexField",
3398+
"fields": [
3399+
{
3400+
"name": "producerIndex"
3401+
}
3402+
]
3403+
},
33823404
{
33833405
"condition": {
33843406
"typeReachable": "io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField"

tests/src/io.netty/netty-common/4.1.115.Final/src/test/java/netty/NettyTests.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
import io.netty.bootstrap.Bootstrap;
2121
import io.netty.bootstrap.ServerBootstrap;
22+
import io.netty.buffer.AdaptiveByteBufAllocator;
2223
import io.netty.buffer.Unpooled;
2324
import io.netty.channel.Channel;
2425
import io.netty.channel.ChannelFutureListener;
2526
import io.netty.channel.ChannelHandlerContext;
2627
import io.netty.channel.ChannelInitializer;
28+
import io.netty.channel.ChannelOption;
2729
import io.netty.channel.ChannelPipeline;
2830
import io.netty.channel.EventLoopGroup;
2931
import io.netty.channel.SimpleChannelInboundHandler;
@@ -71,12 +73,17 @@ public class NettyTests {
7173

7274
@Test
7375
void withSsl() throws Exception {
74-
test(true);
76+
test(true, false);
7577
}
7678

7779
@Test
7880
public void noSsl() throws Exception {
79-
test(false);
81+
test(false, false);
82+
}
83+
84+
@Test
85+
public void withAdaptive() throws Exception {
86+
test(true, true);
8087
}
8188

8289
@Test
@@ -109,13 +116,13 @@ void testNioServerSocketChannel() {
109116
}
110117
}
111118

112-
private void test(boolean ssl) throws Exception {
119+
private void test(boolean ssl, boolean withAdaptive) throws Exception {
113120
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
114121
EventLoopGroup workerGroup = new NioEventLoopGroup();
115122
try {
116-
startServer(bossGroup, workerGroup, ssl);
123+
startServer(bossGroup, workerGroup, ssl, withAdaptive);
117124
AtomicReference<Response> response = new AtomicReference<>();
118-
startClient(workerGroup, ssl, response::set);
125+
startClient(workerGroup, ssl, withAdaptive, response::set);
119126
Awaitility.await().atMost(Duration.ofSeconds(5))
120127
.untilAtomic(response, CoreMatchers.equalTo(new Response(200, "HTTP/1.1", "Hello World")));
121128
} finally {
@@ -132,13 +139,16 @@ private InputStream loadCert() {
132139
return Objects.requireNonNull(NettyTests.class.getResourceAsStream("/cert.pem"), "/cert.pem not found");
133140
}
134141

135-
private void startClient(EventLoopGroup group, boolean ssl, Consumer<Response> callback) throws InterruptedException, SSLException {
142+
private void startClient(EventLoopGroup group, boolean ssl, boolean withAdaptive, Consumer<Response> callback) throws InterruptedException, SSLException {
136143
SslContext sslContext = null;
137144
if (ssl) {
138145
sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
139146
}
140147
Bootstrap b = new Bootstrap();
141148
b.group(group).channel(NioSocketChannel.class).handler(new HttpClientInitializer(sslContext, callback));
149+
if (withAdaptive) {
150+
b.option(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator());
151+
}
142152
Channel ch = b.connect("localhost", PORT).sync().channel();
143153
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/", Unpooled.EMPTY_BUFFER);
144154
request.headers().set(HttpHeaderNames.HOST, "localhost");
@@ -147,7 +157,7 @@ private void startClient(EventLoopGroup group, boolean ssl, Consumer<Response> c
147157
ch.closeFuture().sync();
148158
}
149159

150-
private void startServer(EventLoopGroup bossGroup, EventLoopGroup workerGroup, boolean ssl) throws InterruptedException, SSLException {
160+
private void startServer(EventLoopGroup bossGroup, EventLoopGroup workerGroup, boolean ssl, boolean withAdaptive) throws InterruptedException, SSLException {
151161
SslContext sslContext = null;
152162
if (ssl) {
153163
sslContext = SslContextBuilder.forServer(loadCert(), loadKey(), null).build();
@@ -157,6 +167,10 @@ private void startServer(EventLoopGroup bossGroup, EventLoopGroup workerGroup, b
157167
.channel(NioServerSocketChannel.class)
158168
.handler(new LoggingHandler(LogLevel.INFO))
159169
.childHandler(new HttpServerInitializer(sslContext));
170+
if (withAdaptive) {
171+
b.option(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator())
172+
.childOption(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator());
173+
}
160174
b.bind(PORT).sync();
161175
}
162176

0 commit comments

Comments
 (0)