From 24c6b599c464a6c667319ae61efb159de09c705d Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 31 Dec 2014 19:24:53 +0900 Subject: [PATCH] Make sure AggregatedFullHttpMessage.trailingHeaders() return non-null When handling an oversized message, HttpObjectAggregator does not wait until the last chunk is received to produce the failed message, making AggregatedFullHttpMessage.trailingHeaders() return null. --- .../codec/http/HttpObjectAggregator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java index 76961f677c..864dd875d4 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java @@ -192,17 +192,23 @@ public class HttpObjectAggregator protected final HttpMessage message; private HttpHeaders trailingHeaders; - private AggregatedFullHttpMessage(HttpMessage message, ByteBuf content, HttpHeaders trailingHeaders) { + AggregatedFullHttpMessage(HttpMessage message, ByteBuf content, HttpHeaders trailingHeaders) { super(content); this.message = message; this.trailingHeaders = trailingHeaders; } + @Override public HttpHeaders trailingHeaders() { - return trailingHeaders; + HttpHeaders trailingHeaders = this.trailingHeaders; + if (trailingHeaders == null) { + return HttpHeaders.EMPTY_HEADERS; + } else { + return trailingHeaders; + } } - public void setTrailingHeaders(HttpHeaders trailingHeaders) { + void setTrailingHeaders(HttpHeaders trailingHeaders) { this.trailingHeaders = trailingHeaders; } @@ -265,7 +271,7 @@ public class HttpObjectAggregator private static final class AggregatedFullHttpRequest extends AggregatedFullHttpMessage implements FullHttpRequest { - private AggregatedFullHttpRequest(HttpRequest request, ByteBuf content, HttpHeaders trailingHeaders) { + AggregatedFullHttpRequest(HttpRequest request, ByteBuf content, HttpHeaders trailingHeaders) { super(request, content, trailingHeaders); } @@ -373,7 +379,8 @@ public class HttpObjectAggregator private static final class AggregatedFullHttpResponse extends AggregatedFullHttpMessage implements FullHttpResponse { - private AggregatedFullHttpResponse(HttpResponse message, ByteBuf content, HttpHeaders trailingHeaders) { + + AggregatedFullHttpResponse(HttpResponse message, ByteBuf content, HttpHeaders trailingHeaders) { super(message, content, trailingHeaders); }