src/main/java/org/java_websocket/framing/CloseFrame.java
private void validateUtf8(ByteBuffer payload, int mark) throws InvalidDataException {
        try {
            payload.position( payload.position() + 2 );
            reason = Charsetfunctions.stringUtf8( payload );
        } catch ( IllegalArgumentException e ) {
            throw new InvalidDataException( CloseFrame.NO_UTF8 );
        } finally {
            payload.position( mark );
        }
    }
private void validateUtf8(ByteBuffer payload, int mark) throws InvalidDataException {
        try {
            payload.position( payload.position() + 2 );
            reason = Charsetfunctions.stringUtf8( payload );
        } catch ( IllegalArgumentException e ) {
            throw new InvalidDataException( CloseFrame.NO_UTF8 );
        } finally {
            payload.position( mark );
        }
    }
Validate the payload to valid utf8
@param mark the current mark
@param payload the current payload
@throws InvalidDataException the current payload is not a valid utf8