update to netty 4.1.52, add exception handler for HTTP pipeline handler

This commit is contained in:
Jörg Prante 2020-09-10 18:11:53 +02:00
parent ea640122d8
commit 57af07c950
3 changed files with 23 additions and 5 deletions

View file

@ -1,19 +1,19 @@
group = org.xbib group = org.xbib
name = netty-http name = netty-http
version = 4.1.51.5 version = 4.1.52.0
gradle.wrapper.version = 6.4.1 gradle.wrapper.version = 6.4.1
netty.version = 4.1.51.Final netty.version = 4.1.52.Final
tcnative.version = 2.0.31.Final tcnative.version = 2.0.34.Final
xbib.net.version = 2.1.0
bouncycastle.version = 1.66 bouncycastle.version = 1.66
reactivestreams.version = 1.0.2 reactivestreams.version = 1.0.2
xbib-guice.version = 4.0.4
reactivex.version = 1.3.8 reactivex.version = 1.3.8
conscrypt.version = 2.4.0 conscrypt.version = 2.4.0
javassist.version = 3.27.0-GA javassist.version = 3.27.0-GA
jackson.version = 2.11.1 jackson.version = 2.11.1
mockito.version = 3.4.4 mockito.version = 3.4.4
xbib.net.version = 2.1.0
xbib-guice.version = 4.0.4
# uuhh, too many tests to update to jupiter in rx... # uuhh, too many tests to update to jupiter in rx...
junit.version = 5.6.2 junit.version = 5.6.2
junit4.version = 4.13 junit4.version = 4.13

View file

@ -100,6 +100,7 @@ public final class Server implements AutoCloseable {
* @param parentEventLoopGroup parent event loop group * @param parentEventLoopGroup parent event loop group
* @param childEventLoopGroup child event loop group * @param childEventLoopGroup child event loop group
* @param socketChannelClass socket channel class * @param socketChannelClass socket channel class
* @param executor an extra blocking thread pool executor or null
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Server(DefaultServerConfig serverConfig, private Server(DefaultServerConfig serverConfig,

View file

@ -1,15 +1,22 @@
package org.xbib.netty.http.server.protocol.http1; package org.xbib.netty.http.server.protocol.http1;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.LastHttpContent; import io.netty.handler.codec.http.LastHttpContent;
import java.nio.charset.StandardCharsets;
import java.util.PriorityQueue; import java.util.PriorityQueue;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Implements HTTP pipelining ordering, ensuring that responses are completely served in the same order as their * Implements HTTP pipelining ordering, ensuring that responses are completely served in the same order as their
@ -19,6 +26,8 @@ import java.util.concurrent.locks.ReentrantLock;
*/ */
public class HttpPipeliningHandler extends ChannelDuplexHandler { public class HttpPipeliningHandler extends ChannelDuplexHandler {
private final Logger logger = Logger.getLogger(HttpPipeliningHandler.class.getName());
private final int pipelineCapacity; private final int pipelineCapacity;
private final Lock lock; private final Lock lock;
@ -80,4 +89,12 @@ public class HttpPipeliningHandler extends ChannelDuplexHandler {
super.write(ctx, msg, promise); super.write(ctx, msg, promise);
} }
} }
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
logger.log(Level.SEVERE, cause.getMessage(), cause);
ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.INTERNAL_SERVER_ERROR,
Unpooled.copiedBuffer(cause.getMessage().getBytes(StandardCharsets.UTF_8))));
}
} }