TakahikoKawasaki / nv-websocket-client

High-quality WebSocket client implementation in Java.
Apache License 2.0
2.03k stars 292 forks source link

NullPointerException on writeThread #220

Closed joseparis113 closed 3 years ago

joseparis113 commented 3 years ago

In WebSocketOutputStream.java an exception is thrown at writeFramePayload when payload is returned as null from frame.getPayload() because the test for nullity is done after checking for payload.length. It should be done after that check:

private void writeFramePayload(WebSocketFrame frame, byte[] maskingKey) throws IOException { byte[] payload = frame.getPayload(); byte[] masked = new byte[payload.length]; if (payload == null) { return; } .......................

Should be: ........... if (payload == null) { return; } byte[] masked = new byte[payload.length]; ...........