Buggy code:
public class DiscordWebSocketClient extends WebSocketClient { private static final Logger LOGGER = LoggerFactory . getLogger ( "DiscordApiWebSocketClient" ) ; private static Map < String , String > header ; private final DiscordApiClient . DiscordApiClient apiClient ; private final JSONParser parser ; private final Gson gson ; private final DiscordWebSocketClient . Statistics statistics ; private ScheduledFuture keepAliveFuture ; public DiscordWebSocketClient ( DiscordApiClient . DiscordApiClient apiClient , URI serverUri ) { } @ Override public void onOpen ( ServerHandshake handshakedata ) { } @ Override public void onMessage ( String message ) { long start = System . nanoTime ( ) ; try { DiscordWebSocketClient . LOGGER . trace ( "Recieved<seq2seq4repair_space>message:<seq2seq4repair_space>{}" , message ) ; statistics . messageReceiveCount . increment ( ) ; try { JSONObject msg = ( ( JSONObject ) ( parser . parse ( message ) ) ) ; String errorMessage = ( ( String ) ( msg . get ( "message" ) ) ) ; if ( errorMessage != null ) { if ( errorMessage . isEmpty ( ) ) { DiscordWebSocketClient . LOGGER . warn ( "[0]<seq2seq4repair_space>'':<seq2seq4repair_space>Discord<seq2seq4repair_space>returned<seq2seq4repair_space>an<seq2seq4repair_space>unknown<seq2seq4repair_space>error" ) ; } else { DiscordWebSocketClient . LOGGER . warn ( "[0]<seq2seq4repair_space>'':<seq2seq4repair_space>Discord<seq2seq4repair_space>returned<seq2seq4repair_space>error:<seq2seq4repair_space>{}" , errorMessage ) ; } statistics . errorCount . increment ( ) ; return ; } <START_BUG> int opCode = ( ( int ) ( msg . get ( "op" ) ) ) ; <END_BUG> if ( opCode != 0 ) { DiscordWebSocketClient . LOGGER . warn ( "Unknown<seq2seq4repair_space>opcode<seq2seq4repair_space>{}<seq2seq4repair_space>received:<seq2seq4repair_space>{}" , opCode , message ) ; return ; } String type = ( ( String ) ( msg . get ( "t" ) ) ) ; JSONObject data = ( ( JSONObject ) ( msg . get ( "d" ) ) ) ; switch ( type ) { case "READY" : handleReadyMessage ( data ) ; break ; case "GUILD_MEMBERS_CHUNK" : handleGuildMembersChunk ( data ) ; break ; case "USER_UPDATE" : handleUserUpdate ( data ) ; break ; case "USER_SETTINGS_UPDATE" : break ; case "MESSAGE_CREATE" : handleMessageCreate ( data ) ; break ; case "MESSAGE_UPDATE" : handleMessageUpdate ( data ) ; break ; case "MESSAGE_DELETE" : handleMessageDelete ( data ) ; break ; case "TYPING_START" : break ; case "GUILD_CREATE" : handleGuildCreate ( data ) ; break ; case "GUILD_DELETE" : handleGuildDelete ( data ) ; break ; case "GUILD_MEMBER_ADD" : handleGuildMemberAdd ( data ) ; break ; case "GUILD_MEMBER_REMOVE" : handleGuildMemberRemove ( data ) ; break ; case "GUILD_MEMBER_UPDATE" : handleGuildMemberUpdate ( data ) ; break ; case "GUILD_ROLE_CREATE" : handleGuildRoleCreate ( data ) ; break ; case "GUILD_ROLE_DELETE" : handleGuildRoleDelete ( data ) ; break ; case "GUILD_ROLE_UPDATE" : handleGuildRoleUpdate ( data ) ; break ; case "CHANNEL_CREATE" : handleChannelCreate ( data ) ; break ; case "CHANNEL_DELETE" : handleChannelDelete ( data ) ; break ; case "CHANNEL_UPDATE" : handleChannelUpdate ( data ) ; break ; case "PRESENCE_UPDATE" : handlePresenceUpdate ( data , message ) ; break ; case "VOICE_STATE_UPDATE" : handleVoiceStateUpdate ( data ) ; break ; case "VOICE_SERVER_UPDATE" : handleVoiceServerUpdate ( data ) ; break ; case "GUILD_BAN_ADD" : handleGuildBanAdd ( data ) ; break ; case "GUILD_BAN_DELETE" : handleGuildBanDelete ( data ) ; break ; default : DiscordWebSocketClient . LOGGER . warn ( "[0]<seq2seq4repair_space>\'\':<seq2seq4repair_space>Unknown<seq2seq4repair_space>message<seq2seq4repair_space>type<seq2seq4repair_space>{}:\n{}" , type , data . toJSONString ( ) ) ; } } catch ( Exception e ) { DiscordWebSocketClient . LOGGER . warn ( "[0]<seq2seq4repair_space>'':<seq2seq4repair_space>Unable<seq2seq4repair_space>to<seq2seq4repair_space>parse<seq2seq4repair_space>message" , e ) ; } } finally { statistics . avgMessageHandleTime . add ( TimeUnit . MILLISECONDS . convert ( ( ( System . nanoTime ( ) ) - start ) , TimeUnit . NANOSECONDS ) ) ; } } private void handleGuildBanDelete ( JSONObject data ) { } private void handleGuildBanAdd ( JSONObject data ) { } private void handleMessageDelete ( JSONObject data ) { } private void handleMessageUpdate ( JSONObject data ) { } private void handleGuildMembersChunk ( JSONObject data ) { } private void handleUserUpdate ( JSONObject data ) { } private void handleVoiceStateUpdate ( JSONObject data ) { } private void handleVoiceServerUpdate ( JSONObject data ) { } private void handleGuildRoleUpdate ( JSONObject data ) { } private void handleGuildRoleDelete ( JSONObject data ) { } private void handleGuildRoleCreate ( JSONObject data ) { } private void handlePresenceUpdate ( JSONObject data , String raw ) { } private void handleGuildMemberUpdate ( JSONObject data ) { } private void handleGuildMemberRemove ( JSONObject data ) { } private void handleGuildMemberAdd ( JSONObject data ) { } private void handleChannelUpdate ( JSONObject data ) { } private void handleChannelDelete ( JSONObject data ) { } private void handleChannelCreate ( JSONObject data ) { } private void handleReadyMessage ( JSONObject data ) { } private void handleGuildCreate ( JSONObject data ) { } private void handleGuildDelete ( JSONObject data ) { } @ SuppressWarnings ( "unchecked" ) private void startKeepAlive ( long keepAliveInterval ) { } private void handleMessageCreate ( JSONObject data ) { } @ Override public void onClose ( int code , String reason , boolean remote ) { } @ Override public void onError ( Exception ex ) { } void sendNowPlayingUpdate ( String message ) { } private < T > T jsonObjectToObject ( JSONObject object , Class < T > clazz ) { } public DiscordWebSocketClient . Statistics getStatistics ( ) { } public static class Statistics { public final RunningAverage avgMessageHandleTime = new RunningAverage ( ) ; public final LongAdder messageReceiveCount = new LongAdder ( ) ; public final LongAdder keepAliveCount = new LongAdder ( ) ; public final LongAdder errorCount = new LongAdder ( ) ; public final LongAdder deathCount = new LongAdder ( ) ; } }

Fix:
int opCode = ( ( Number ) ( msg . get ( "op" ) ) ) . intValue ( ) ;