Fixed NPE in WebSocket00FrameDecoder if end couldn't be found in text frame

Motivation:
When we receive an incomplete WebSocketFrame we need to make sure to wait for more data. Because we not did this we could produce a NPE.

Modification:
Make sure we not try to add null into the RecyclableArrayList

Result:
no more NPE on incomplete frames.
This commit is contained in:
Gernot Pansy 2014-07-16 13:39:03 +02:00 committed by Norman Maurer
parent 7e76cbd689
commit d8a78424b3

View File

@ -62,12 +62,17 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder<Void> implements W
// Decode a frame otherwise.
byte type = in.readByte();
WebSocketFrame frame;
if ((type & 0x80) == 0x80) {
// If the MSB on type is set, decode the frame length
out.add(decodeBinaryFrame(ctx, type, in));
frame = decodeBinaryFrame(ctx, type, in);
} else {
// Decode a 0xff terminated UTF-8 string
out.add(decodeTextFrame(ctx, in));
frame = decodeTextFrame(ctx, in);
}
if (frame != null) {
out.add(frame);
}
}