Source:
private MessageEventCallback getMessageCallback() { return new MessageEventCallback() { @Override public void doCallback(String message) { } @Override public void onConnectionOpen(Object session) { } @Override public void onConnectionClose(final CloseReason reason) { try { frontendSession.close(reason.getCloseCode().getCode(), reason.getReasonPhrase()); } finally { cleanup(); } } @Override public void onError(Throwable cause) { cleanupOnError(cause); } @Override public void onMessageText(String message, Object session) { LOG.logMessage("[From Backend <---]" + message); remoteLock.lock(); final RemoteEndpoint remote = getRemote(); if (remote == null) { LOG.logMessage("Remote endpoint is null"); if (messageBuffer == null) { messageBuffer = new ArrayList<String>(); } if (messageBuffer.size() >= MAX_BUFFER_MESSAGE_COUNT) { throw new RuntimeIOException("Remote is null and message buffer is full. Cannot buffer anymore "); } LOG.logMessage("Buffering message: " + message); messageBuffer.add(message); remoteLock.unlock(); return; } try { if (messageBuffer != null) { LOG.logMessage("Found old buffered messages"); for(String obj:messageBuffer) { LOG.logMessage("Sending old buffered message [From Backend <---]: " + obj); remote.sendString(obj); } messageBuffer = null; } LOG.logMessage("Sending current message [From Backend <---]: " + message); remote.sendString(message); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException e) { LOG.connectionFailed(e); throw new RuntimeIOException(e); } finally { remoteLock.unlock(); } } @Override public void onMessageBinary(byte[] message, boolean last, Object session) { throw new UnsupportedOperationException( "Websocket support for binary messages is not supported at this time."); } }; }

Target:
private MessageEventCallback getMessageCallback() { return new MessageEventCallback() { @Override public void doCallback(String message) { } @Override public void onConnectionOpen(Object session) { } @Override public void onConnectionClose(final CloseReason reason) { try { frontendSession.close(reason.getCloseCode().getCode(), reason.getReasonPhrase()); } finally { cleanup(); } } @Override public void onError(Throwable cause) { cleanupOnError(cause); } @Override public void onMessageText(String message, Object session) { LOG.logMessage("[From Backend <---]" + message); remoteLock.lock(); final RemoteEndpoint remote = getRemote(); try { if (remote == null) { LOG.debugLog("Remote endpoint is null"); if (messageBuffer.size() >= config.getWebsocketMaxWaitBufferCount()) { throw new RuntimeIOException("Remote is null and message buffer is full. Cannot buffer anymore "); } LOG.debugLog("Buffering message: " + message); messageBuffer.add(message); return; } LOG.debugLog("Found old buffered messages"); for (String obj:messageBuffer) { LOG.debugLog("Sending old buffered message [From Backend <---]: " + obj); remote.sendString(obj); } messageBuffer.clear(); LOG.debugLog("Sending current message [From Backend <---]: " + message); remote.sendString(message); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException e) { LOG.connectionFailed(e); throw new RuntimeIOException(e); } finally { remoteLock.unlock(); } } @Override public void onMessageBinary(byte[] message, boolean last, Object session) { throw new UnsupportedOperationException( "Websocket support for binary messages is not supported at this time."); } }; }