Buggy code:
public class WebSocketFrame { public static final int MAX_HEADER_LENGTH = 14 ; private boolean fin ; private WebSocketFrame . OpCode opcode ; private WebSocketFrame . StatusCode statusCode ; private boolean mask ; private long payloadLength ; private byte [ ] maskingKey ; private ByteBuffer data ; private ByteBuffer encoded ; public enum OpCode { Continuation ( 0 ) , Text ( 1 ) , Binary ( 2 ) , ConnectionClose ( 8 ) , Ping ( 9 ) , Pong ( 10 ) ; private final int opcode ; OpCode ( int opcode ) { } public int getOpCodeNumber ( ) { } @ Override public String toString ( ) { } public static WebSocketFrame . OpCode getOpCodeByNumber ( int opcode ) { } } public enum StatusCode { NormalClose ( 1000 ) , ProtocolErrorClose ( 1002 ) , MessageTooBig ( 1009 ) ; private final int statusCode ; StatusCode ( int statusCode ) { } public int getStatusCodeNumber ( ) { } @ Override public String toString ( ) { } } public static WebSocketFrame decode ( UpgradeProcessor < ? > processor ) throws IOException { int i = processor . read ( ) ; boolean fin = ( i & 128 ) > 0 ; boolean rsv1 = ( i & 64 ) > 0 ; boolean rsv2 = ( i & 32 ) > 0 ; boolean rsv3 = ( i & 16 ) > 0 ; if ( ( rsv1 || rsv2 ) || rsv3 ) { } WebSocketFrame . OpCode opCode = WebSocketFrame . OpCode . getOpCodeByNumber ( ( i & 15 ) ) ; WebSocketFrame . validateOpCode ( opCode ) ; i = processor . read ( ) ; <START_BUG> boolean mask = ( i & 128 ) == 0 ; <END_BUG> if ( ! mask ) { throw new IOException ( ) ; } long payloadLength = i & 127 ; if ( payloadLength == 126 ) { byte [ ] extended = new byte [ 2 ] ; processor . read ( extended ) ; payloadLength = Conversions . byteArrayToLong ( extended ) ; } else if ( payloadLength == 127 ) { byte [ ] extended = new byte [ 8 ] ; processor . read ( extended ) ; payloadLength = Conversions . byteArrayToLong ( extended ) ; } byte [ ] maskingKey = new byte [ 4 ] ; processor . read ( maskingKey ) ; WebSocketFrame frame = new WebSocketFrame ( fin , opCode , mask , payloadLength , maskingKey ) ; return frame ; } private static void validateOpCode ( WebSocketFrame . OpCode opCode ) throws IOException { } public InputStream encode ( ) { } public static WebSocketFrame closeFrame ( ) { } public static WebSocketFrame protocolErrorCloseFrame ( ) { } public static WebSocketFrame message ( String message ) { } public WebSocketFrame ( ByteBuffer data ) { } public WebSocketFrame ( boolean fin , WebSocketFrame . OpCode opcode , long payloadLength ) { } public WebSocketFrame ( boolean fin , WebSocketFrame . OpCode opcode , boolean mask , long payloadLength , byte [ ] maskingKey ) { } public WebSocketFrame ( boolean fin , WebSocketFrame . OpCode opcode , boolean mask , long payloadLength , byte [ ] maskingKey , ByteBuffer data ) { } @ Override public String toString ( ) { } public boolean isFin ( ) { } public void setFin ( boolean fin ) { } public WebSocketFrame . OpCode getOpcode ( ) { } public void setOpcode ( WebSocketFrame . OpCode opcode ) { } public WebSocketFrame . StatusCode getStatusCode ( ) { } public void setStatusCode ( WebSocketFrame . StatusCode statusCode ) { } public boolean isClose ( ) { } public boolean isMask ( ) { } public void setMask ( boolean mask ) { } public boolean isData ( ) { } public boolean isControl ( ) { } public long getPayloadLength ( ) { } public void setPayloadLength ( long payloadLength ) { } public byte [ ] getMaskingKey ( ) { } public void setMaskingKey ( byte [ ] maskingKey ) { } protected ByteBuffer getDataAsByteBuffer ( ) { } public ByteBuffer getDataCopy ( ) { } public void setData ( ByteBuffer data ) { } }

Fix:
boolean mask = ( i & 128 ) > 0 ;