[#1671] Fix bug in ChunkedWriteHandler which produce a NPE on empty chunks

This commit is contained in:
Norman Maurer 2013-07-29 16:23:43 +02:00
parent 0cb3541b53
commit 00f1533fa9

View File

@ -15,6 +15,7 @@
*/ */
package io.netty.handler.stream; package io.netty.handler.stream;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
@ -260,6 +261,12 @@ public class ChunkedWriteHandler
break; break;
} }
if (message == null) {
// If message is null write an empty ByteBuf.
// See https://github.com/netty/netty/issues/1671
message = Unpooled.EMPTY_BUFFER;
}
pendingWrites.incrementAndGet(); pendingWrites.incrementAndGet();
ChannelFuture f = ctx.write(message); ChannelFuture f = ctx.write(message);
if (endOfInput) { if (endOfInput) {