Source:
<code>public HandlerStatus onRead() { src.flip(); try { while (src.hasRemaining()) { boolean trusted = isEndpointTrusted(); boolean complete = activeReader.readFrom(src, trusted); if (!complete) { break; } ClientMessage.Frame firstFrame = activeReader.getClientMessage().getStartFrame(); int flags = firstFrame.flags; if (ClientMessage.isFlagSet(flags, UNFRAGMENTED_MESSAGE)) { handleMessage(activeReader.getClientMessage()); } else if (!trusted) { throw new IllegalStateException( "Fragmented client messages are not allowed before the client is authenticated."); } else { <START> ClientMessage message = activeReader.getClientMessage(); ClientMessage.ForwardFrameIterator frameIterator = message.frameIterator(); frameIterator.next(); ClientMessage.Frame startFrame = frameIterator.next(); long fragmentationId = Bits.readLongL(firstFrame.content, FRAGMENTATION_ID_OFFSET); if (ClientMessage.isFlagSet(flags, BEGIN_FRAGMENT_FLAG)) { builderBySessionIdMap.put(fragmentationId, new ClientMessage(startFrame, message.getEndFrame())); <END> } else if (ClientMessage.isFlagSet(flags, END_FRAGMENT_FLAG)) { ClientMessage clientMessage = mergeIntoExistingClientMessage(fragmentationId); handleMessage(clientMessage); } else { mergeIntoExistingClientMessage(fragmentationId); } } activeReader = new ClientMessageReader(maxMessageLength); } return CLEAN; } finally { compactOrClear(src); } }</code><technical_language>Good finding. I cleanups. Instead of creating a new message, put message builderBySessionIdMap . need dropFragmentationFrame . ClientMessage message = activeReader.getClientMessage(); message.dropFragmentationFrame(); long fragmentationId = Bits.readLongL(firstFrame.content, FRAGMENTATION_ID_OFFSET); if (ClientMessage.isFlagSet(flags, BEGIN_FRAGMENT_FLAG)) { builderBySessionIdMap.put(fragmentationId, message); a new method ClientMessage: public void dropFragmentationFrame() { startFrame = startFrame.next; } merge method change accordingly. Dropping fragmentation logic there, feeling wrong with. public void merge(ClientMessage fragment) { endFrame.next = fragment.startFrame; endFrame = fragment.endFrame; } @mdumandag</technical_language>

Target:
public HandlerStatus onRead() { src.flip(); try { while (src.hasRemaining()) { boolean trusted = isEndpointTrusted(); boolean complete = activeReader.readFrom(src, trusted); if (!complete) { break; } ClientMessage.Frame firstFrame = activeReader.getClientMessage().getStartFrame(); int flags = firstFrame.flags; if (ClientMessage.isFlagSet(flags, UNFRAGMENTED_MESSAGE)) { handleMessage(activeReader.getClientMessage()); } else if (!trusted) { throw new IllegalStateException( "Fragmented client messages are not allowed before the client is authenticated."); } else { ClientMessage message = activeReader.getClientMessage(); message.dropFragmentationFrame(); long fragmentationId = Bits.readLongL(firstFrame.content, FRAGMENTATION_ID_OFFSET); if (ClientMessage.isFlagSet(flags, BEGIN_FRAGMENT_FLAG)) { builderBySessionIdMap.put(fragmentationId, message); } else if (ClientMessage.isFlagSet(flags, END_FRAGMENT_FLAG)) { ClientMessage clientMessage = mergeIntoExistingClientMessage(fragmentationId); handleMessage(clientMessage); } else { mergeIntoExistingClientMessage(fragmentationId); } } activeReader = new ClientMessageReader(maxMessageLength); } return CLEAN; } finally { compactOrClear(src); } }