public synchronized HornetQBuffer getBodyBufferCopy() { // Must copy buffer before sending it HornetQBuffer newBuffer = buffer.copy(0, buffer.capacity()); newBuffer.setIndex(0, getEndOfBodyPosition()); return new ResetLimitWrappedHornetQBuffer(BODY_OFFSET, newBuffer, null); }
private void forceCopy() { // Must copy buffer before sending it buffer = buffer.copy(0, buffer.capacity()); buffer.setIndex(0, getEndOfBodyPosition()); if (bodyBuffer != null) { bodyBuffer.setBuffer(buffer); } bufferUsed = false; }
public synchronized HornetQBuffer getEncodedBuffer() { HornetQBuffer buff = encodeToBuffer(); if (bufferUsed) { HornetQBuffer copied = buff.copy(0, buff.capacity()); copied.setIndex(0, endOfMessagePosition); return copied; } else { buffer.setIndex(0, endOfMessagePosition); bufferUsed = true; return buffer; } }