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 f88dfd0430
commit 7d8d9b2c6e

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);
}
}